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
TristanKuesters
Resolver I
Resolver I

Group row data and add as a new column

Hello everybody,

 

if have the following example:

 

Source Table

 

Order No - Amount - Group

1000 - 100€ - A

2000 - 200€ - A

3000 - 400€ - B

 

The result should be a table like this:

Order No - Amount - Group - Group Amount

1000 - 100€ - A - 300€

2000 - 200€ - A - 300€

3000 - 400€ - B - 400€

 

I think, I have to do create a calculated column with calculation and a kind of allselected or simular.

But I don't get it, to group or filter bei the column "Group".

 

Can somebody help?

 

Kind regards,

Tristan

1 ACCEPTED SOLUTION
ankitpatira
Community Champion
Community Champion

@TristanKuesters What I would suggest easiest option would be is to go to power bi desktop query editor -> right click your original query and click Reference. This would create another query that is referenced original. Then for the second group do Group By via Transorm tab that will give you sum of Amount by Group. Close&Apply and then create relationship between two queries using Group column. 

 

So you will end up with query that is grouped by sum of amount like how you wanted and you will also have original query that also contains order number column.

View solution in original post

3 REPLIES 3
cbl
Frequent Visitor

Hi Tristan,

 

A much easier solution is to choose "Merge Queries" in Query Editor in the original query. Then do a self-referencing left join on the column which you wish to group by. This will add a new column to the original query containing a table in each row. Click the two arrows in the column header and choose "aggregate" to sum the amount for each of your groups.

 

Best regards,

Christian

ankitpatira
Community Champion
Community Champion

@TristanKuesters What I would suggest easiest option would be is to go to power bi desktop query editor -> right click your original query and click Reference. This would create another query that is referenced original. Then for the second group do Group By via Transorm tab that will give you sum of Amount by Group. Close&Apply and then create relationship between two queries using Group column. 

 

So you will end up with query that is grouped by sum of amount like how you wanted and you will also have original query that also contains order number column.

It works. Thanks a lot.

Sometime the solution is so simple.

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.