Forum Discussion
Want to organize my data using Transform Data
- 4 years ago
Ayappan not sure why you would want to do that 🙂 but I created a dax for this table (looks almost like what you want):
Table With Totals = VAR _data = 'Table' VAR _totlas = ADDCOLUMNS( VALUES('Table'[Year]), "Type", "Total", "Sold", CALCULATE(SUM('Table'[Sold])), "Cost", CALCULATE(SUM('Table'[Cost])), "Price", CALCULATE(SUM('Table'[Price])) ) VAR _union = UNION( _data, _totlas ) VAR _result_with_sorting = ADDCOLUMNS( _union, "Sorting", 'Table'[Year] & RIGHT([Type]) ) RETURN _result_with_sorting
You need to sort the table in the model by the Sorting column like in the photo:
This is the updated file with my solution:
Totals.pbix
AyappanIf you put your data as it is in a matrix you get it straightforawrd (attached):
Totals.pbix
Or you mean you want to create a caclulated table with the new structure?
Thanks SpartaBI for the response
I want to create a caclulated table with the new structure..
- SpartaBI4 years agoCommunity Champion
Ayappan not sure why you would want to do that 🙂 but I created a dax for this table (looks almost like what you want):
Table With Totals = VAR _data = 'Table' VAR _totlas = ADDCOLUMNS( VALUES('Table'[Year]), "Type", "Total", "Sold", CALCULATE(SUM('Table'[Sold])), "Cost", CALCULATE(SUM('Table'[Cost])), "Price", CALCULATE(SUM('Table'[Price])) ) VAR _union = UNION( _data, _totlas ) VAR _result_with_sorting = ADDCOLUMNS( _union, "Sorting", 'Table'[Year] & RIGHT([Type]) ) RETURN _result_with_sorting
You need to sort the table in the model by the Sorting column like in the photo:
This is the updated file with my solution:
Totals.pbix