Add output as input into another callback


I have a callback output that I want to add as input into another callback (need the sum of multiple outputs later on).

So I thought to use dbc.Store to store the output of the first callback which is Transport_Zement_gwp2 and to use this as input into the second callback.

However, it seems that the data whcih is stored is not passed on into the second callback, as it returns nothing.

Can anyone help out how I to modify this?

Thank you!


    [dash.dependencies.Output('Zement_gesamt_gwp', 'children'),
    dash.dependencies.Output('Transport_zement_gwp', 'children'),
    dash.dependencies.Output('Transport_zement_gwp2', 'data')],
    [dash.dependencies.Input('Werksauswahl', 'value'),
    dash.dependencies.Input('Zementauswahl', 'value'),
    dash.dependencies.Input('Zementmenge_input', 'value'),
    dash.dependencies.Input('Transportauswahl1', 'value'),
    dash.dependencies.Input('Transport_input1', 'value')],

def get_gwp_value (selected_werk, selected_cement, selected_amount, selected_transport, selected_distance):

    if selected_werk is None or selected_cement is None or selected_amount is None or selected_transport is None or selected_distance is None:
        raise dash.exceptions.PreventUpdate


        if selected_amount is not None and selected_distance is not None:
            gwp_z = df['GWP_netto'][(df['Werk']==selected_werk) & (df['Zement']==selected_cement)]
            zement_gwp = gwp_z*selected_amount
            zement_gwp = round(zement_gwp, 2)
            gwp_t = df1['GWP'][(df1['Prozess']==selected_transport)]
            transport_gwp = gwp_t*selected_distance*(selected_amount / 1000)
            transport_z_gwp = round(transport_gwp, 2)
        return zement_gwp.astype(str) + str(' kg CO2/e'), transport_z_gwp.astype(str) + str(' kg CO2/e'), transport_z_gwp.values[0]

    dash.dependencies.Output('Transport_total_all', 'children'),
    dash.dependencies.Input({'type':'Transport_Zement_gwp2', 'index': ALL}, 'data'),



def display_output(zement_trans):
    if zement_trans is None:
        raise dash.exceptions.PreventUpdate

        return zement_trans


are you sure that this

is NOT None? I did not dig into your code, but what you could try is:

initiating the dcc.Store with a default value (type you expect) like this


or instead of transport_z_gwp.values[0] return a constant value from your first output just to see if your callbacks are working as intended.

1 Like


thanks for you reply, I fixed it, I just had to correct the input dash.dependencies.Input({'type':'Transport_Zement_gwp2', 'index': ALL}, 'data') into dash.dependencies.Input('Transport_Zement_gwp2', 'data')

But good to know that my logic was right when I approached the problem.

Thanks again!