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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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

You can do oit like this:

artemus_0-1606242804431.png

 

artemus
Employee
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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors