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

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

Reply
DevM01
Helper I
Helper I

Group by ID and sum a column based on a third column with Power Query.

I have data coming back that look like this: 

IdYearAmount
1201015
1201020
1201220
2201010
2201130
2201140
2201115
3201210
3201320
3201320

 

I want the end result to be like this: 


 

IdYearAmount
1201035
1201220
2201010
2201185
3201210
3201340

 

So for each Id, the year should be unique, and the amount should be summed for that year. Can I do it in Power BI query editor? Do I need to write code for that? 

1 ACCEPTED SOLUTION
artemus
Microsoft Employee
Microsoft Employee

That depends on what you want to show in each other column, since you have fewer rows, you are going to have to determine what to show when those rows are merged for those other Columns. For example, you could add additional aggregates for each column using the max aggregate.

View solution in original post

6 REPLIES 6
artemus
Microsoft Employee
Microsoft Employee

That depends on what you want to show in each other column, since you have fewer rows, you are going to have to determine what to show when those rows are merged for those other Columns. For example, you could add additional aggregates for each column using the max aggregate.

I have the similar issue, Please share if you find any solution to it

@artemus am not sure if I should post this as a new question, but I want to filter the "years" as >= current year, how do we do that? 

artemus
Microsoft Employee
Microsoft Employee

You can do oit like this:

artemus_0-1606242804431.png

 

artemus
Microsoft Employee
Microsoft Employee

What you need to do is a group by:

1. Select both the Id and Year column

2. Choose Group By button.

3. In the aggregations, choose Sum, and for the column choose Amount

4. Name the column Amount

Thanks @artemus .. how do I do that and keep all other columns I already chose in a previous step? When I do the grouping I lose all other columns I had already. For those other columns, they are shared between all, so I'd like keep them the same. 

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 Kudoed Authors