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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Rdata
Advocate I
Advocate I

Merge & Sum Rows in Transform Data based on Multiple Criteria

So I have this table with locations named with IDs. Each ID can have data from multiple years, and multiple metric types. I want to merge and sum all the Water + Irrigation rows with matching ID/Year, and leave all the rest as-is. I want to do this in transform data, because I have other things I need to do with this table and data. Is this possible? 

 

Original Table:

RowIDYearMetric TypeJanuary Use
1122022Water25
2122022Irrigation55
3122021Electrcitiy28160
4122022Electricity19760
54232022Water46
64232022Irrigation33
74232022Natural Gas6340

8

89

2021Electricity21780
9892022Natural Gas180
10552022Water11

 

Desired Table

RowIDYearMetric TypeJanuary Use
1122022Water80
2122021Electrcitiy28160
3122022Electricity19760
44232022Water79
54232022Natural Gas6340

6

89

2021Electricity21780
7892022Natural Gas180
8552022Water11

 

 

1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

My suggestion would be to replace Irrigation as Water using replace values and then group by ID, Year and Metric Type, summing the January Use row. You can add in an index column after if it is needed.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

@Rdata Sure, there is the ability to group rows in Power Query or you can use SUMMARIZE or GROUPBY in DAX.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
jgeddes
Super User
Super User

My suggestion would be to replace Irrigation as Water using replace values and then group by ID, Year and Metric Type, summing the January Use row. You can add in an index column after if it is needed.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





This was such a simple step forward, thank you!

 

Something I left out of my original solution was that I have multiple columns (one for each month), that I needed summed separately, but I actually just unpivoted them, then grouped by ID, Year, Month, and Metric and that seems to have done the trick! 

@Rdata Unpivot for the win!



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.