Dash Data Table Creating a thrid column wich contains the difference of the values in the previous columns

Hey guys,

im new to dash and im trying to make a Dash Datatable with for example 2 generated Columns from a CSV and i want to generate a third next to the others with the difference of the values in the other 2 Columns for each row!

it would be great if i could get some advice.

best regards

Hey @Mae , welcome to community.

Please see links below



First you can calculate the difference between col1 and col2 then append it to your dataset. Then create your data table.

Have a nice day.

Greetings akroma,
thanks alot for your fast reply. I will try it today.

1 Like

Let me know how it goes. Good luck.

1 Like

I Found the solution. Cause i made for every year and week a separated append and so i got three times week 1-53 in year 2015, 2016 and 2018 and week 1-52 in year 2017. so i had 211 rows instead of 53 rows as intended.

1 Like

I solved it by my own my only problem is to change the column header depending on the year i choosed for the column. I think i need an separate output for each

this is the code for the headers of each column:

{“name” : “KW”, “id” : “KW”},
{“name” : ‘Anzahl’+" “+”%s" %year_picker_1, “id”: ‘Anzahl1’},
{“name” : ‘Umsatz’+" “+”%s" %year_picker_1, ‘id’ : ‘Umsatz1’},
{“name” : ‘Anzahl’+" “+”%s" %year_picker_2, “id”: ‘Anzahl2’},
{“name” : ‘Umsatz’+" “+”%s" %year_picker_2, ‘id’ : ‘Umsatz2’},
{“name” : ‘Anzahl’+" “+”%s" %year_picker_3, “id”: ‘Anzahl3’},
{“name” : ‘Umsatz’+" “+”%s" %year_picker_3, ‘id’ : ‘Umsatz3’},
{“name” : ‘Anzahl’+" “+”%s" %year_picker_4, “id”: ‘Anzahl4’},
{“name” : ‘Umsatz’+" “+”%s" %year_picker_4, ‘id’ : ‘Umsatz4’}

can i return values from a callback function without an Output(id, and value?)
and i need only to return the data for the table (is working) and the values from the year_picker (not working)

this is my current Callback:

Output('datatable-interactivity', 'data'),
[Input('year_picker_1', 'value'),
 Input('year_picker_2', 'value'),
 Input('year_picker_3', 'value'),
 Input('year_picker_4', 'value')]

but i need to return the year picker values too, to name the the column headers with the selected your of the dropdown above…

many thanks in advance

Would be nice if you could help me @akroma ^^