Forum Discussion

Ayappan's avatar
Ayappan
Icon for Helper III rankHelper III
4 years ago
Solved

Want to organize my data using Transform Data

Hi ,

    I am having a data like 

YearTypeSoldCostPrice
2020T15006001100
2020T2200500700
2020T3500400900
2020T48003001100
2020T511002001300
2020T6500100600
2020T71300130
2021T15006001100
2021T2200500700
2021T3500400900
2021T48003001100
2021T511002001300
2021T6500100600
2021T71300130
2022T15006001100
2022T2200500700
2022T3500400900
2022T48003001100
2022T511002001300
2022T6500100600
2022T71300130

 

I want to Transform into

YearTypeSoldCostPrice
2020T15006001100
2020T2200500700
2020T3500400900
2020T48003001100
2020T511002001300
2020T6500100600
2020T71300130
Total 373021005830
2021T15006001100
2021T2200500700
2021T3500400900
2021T48003001100
2021T511002001300
2021T6500100600
2021T71300130
Total 373021005830
2022T15006001100
2022T2200500700
2022T3500400900
2022T48003001100
2022T511002001300
2022T6500100600
2022T71300130
Total 373021005830

I want to add a total for other column based on each year ..

Is this posible 

Thanks ..

  • 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



    Showcase Report – Contoso By SpartaBI


          

5 Replies