title: Python Plotly-Dash app using multiple filters as the input
body: <p>I have just started learning Python, and I’m currently exploring Dash.  I am interested in creating a dashboard that has multi-selection options as the input and creates a bar graph as the output.  I am having difficulty with the callbacks recognizing the inputs &amp; summing the data accordingly.  I’ve seen examples of dashboards created using Dash which have an input, but the issue I’m getting is how to be able to sum on the combination of inputs selected, instead of a set combination.  </p>
  
  <p>As an example, using the table:
  <a href="https://i.stack.imgur.com/2loQZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2loQZ.jpg" alt="enter image description here"></a></p>
  
  <pre><code>import dash
  import dash_core_components as dcc
  import dash_html_components as html
  
  import pandas as pd
  import matplotlib.pyplot as plt
  %matplotlib inline
  
  from plotly import __version__
  from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
  import plotly.plotly as py
  import plotly.graph_objs as go
  import plotly.figure_factory as FF
  import numpy as np
  
  df = pd.read_excel('test_file.xlsx', 'Sheet1')
  
  
  type_options = df['TYPE'].unique()
  ind_options = df['IND'].unique()
  
  app = dash.Dash()
  
  app.layout = html.Div(children=[
      html.H1(children='Dashboard', style={
          'textAlign': 'center',
      }),
      html.P('Type'),
      dcc.Dropdown(
          id='typePicker',
          options=[{'label': i, 'value': i} for i in type_options],
          value='A',
          multi=True
      ),
  
      html.P('Ind'),
      dcc.Dropdown(
          id='indPicker',
          options=[{'label': i, 'value': i} for i in ind_options],
          value='1',
          multi=True
      ),
  
      dcc.Graph(
          id='sales-graph'
      )
  ])
  
  
  @app.callback(
      dash.dependencies.Output('sales-graph', 'figure'),
      [dash.dependencies.Input('typePicker', 'value'),
       dash.dependencies.Input('indPicker', 'value')])
  def update_graph(typePicker, indPicker):
  
  
      return {
          'data': [
              go.Bar(
                  x=['April Sales'],                
                  #y=df.groupby(df['TYPE'] == typePicker).sum('April_sales')
                  y=df[df['TYPE'] == typePicker]['April_sales']
              ) 
          ],
          'layout': go.Layout(
              yaxis={'title': 'sales'},
              barmode='stack',
              hovermode='closest'
          )
      }
  
  if __name__ == '__main__':
      app.run_server()
  </code></pre>
  
  <p>I started with one bar for April sales - I would like to add in another bar for May sales as well, but I wanted to get something to work before I add in multiple traces. Right now, running this code shows a bar for April sales for the first instance of "A", since that was set at the default.</p>
  
  <p>I would like to be able to select any combination of type &amp; ind, including multiple options for each (e.g. selecting "A" and "C" for type and "1" for ind would show a bar graph summing April sales across those options).  When I tried using a pivot table, I was only able to get distinct combinations of each.  I also explored using a groupby or an asin but I haven't been able to sum on the inputs as I want.</p>
  
  <p>In Dash, how can multiple inputs be used in the callbacks to update a graph accordingly to multiple selections?  Any suggestions would be greatly appreciated.</p>