cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
TristanKuesters Regular Visitor
Regular Visitor

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

Accepted Solutions
ankitpatira Super Contributor
Super Contributor

Re: Group row data and add as a new column

@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
ankitpatira Super Contributor
Super Contributor

Re: Group row data and add as a new column

@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

TristanKuesters Regular Visitor
Regular Visitor

Re: Group row data and add as a new column

It works. Thanks a lot.

Sometime the solution is so simple.

cbl Frequent Visitor
Frequent Visitor

Re: Group row data and add as a new column

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

Helpful resources

Announcements
Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 285 members 2,813 guests
Please welcome our newest community members: