Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Ayappan
Helper III
Helper III

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 ..

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community 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:

SpartaBI_0-1655192760104.png


This is the updated file with my solution:
Totals.pbix



2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

5 REPLIES 5
Ayappan
Helper III
Helper III

Thank for your reply @SpartaBI 

Yes i want to create a caclulated table with the new structure?

Ayappan
Helper III
Helper III

@SpartaBI Please help me out 

SpartaBI
Community Champion
Community Champion

@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?


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Thanks @SpartaBI for the response 

I want to create a caclulated table with the new structure..

SpartaBI
Community Champion
Community 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:

SpartaBI_0-1655192760104.png


This is the updated file with my solution:
Totals.pbix



2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors