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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

creating an aggregated table

Hi all, I have a table that I want to create an aggregate table based off of. A customer can have multiple customer IDs. I want the desired table to contain all the distinct IDs - no repeats. And revenue in the new table should be the sum of the revenue from the ids (for Harvard, 150+200). Anyone know how to do this?

 

Current table

Customer ID      Customer     Revenue    Region     
1Stanford U100US-West
2Stanford U50US-West
3Harvard U150US-East
3Harvard U200US-East

 

Desired Table

Customer ID  Customer       Total Revenue        Region      
1Stanford U100US-West
2Stanford U50US-West
3Harvard U350US-East
3 ACCEPTED SOLUTIONS
mahoneypat
Microsoft Employee
Microsoft Employee

At least two ways to do this.  

 

1.  Recommended Way - do it in Power Query.  Group By multiple columns (ID, Customer, and Region) and do a sum on the Revenue column.  This will make it so you only have to load one table into your data model.

 

2. Do it with a DAX table.  With this approach, you'll end up with two tables in your data model.  You can ignore the primary table in your analysis, but it will take up filespace.  Click on New Table on the Modelling tab and enter this expression

 

SummaryTable = ADDCOLUMNS(SUMMARIZE(Table, Table[ID], Table[Customer], Table[Region]), "Revenue", Calculate(Sum(Table[Revenue]))) //replace Table with your actual table name

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

MarcoPessina
Resolver IV
Resolver IV

Hi @Anonymous,

you can try this:

Table2 = SUMMARIZECOLUMNS (
    Table1[Customer ID],Table1[Customer],Table1[Region],"Total Revenue", SUMX ( Table1,Table1[Revenue]))

It could be more efficient than using SUMMARIZE according to sqlbi:
https://www.sqlbi.com/articles/introducing-summarizecolumns/ 

 

Hope it helps.

Cheers,

Marco

View solution in original post

v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create calculated table like DAX below.

 

Desired Table = SUMMARIZE(Table1,Table1[Customer ID],Table1[Customer],Table1[Region],"Total Revenue", SUM(Table1[Revenue]))

107.PNG

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create calculated table like DAX below.

 

Desired Table = SUMMARIZE(Table1,Table1[Customer ID],Table1[Customer],Table1[Region],"Total Revenue", SUM(Table1[Revenue]))

107.PNG

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

MarcoPessina
Resolver IV
Resolver IV

Hi @Anonymous,

you can try this:

Table2 = SUMMARIZECOLUMNS (
    Table1[Customer ID],Table1[Customer],Table1[Region],"Total Revenue", SUMX ( Table1,Table1[Revenue]))

It could be more efficient than using SUMMARIZE according to sqlbi:
https://www.sqlbi.com/articles/introducing-summarizecolumns/ 

 

Hope it helps.

Cheers,

Marco

mahoneypat
Microsoft Employee
Microsoft Employee

At least two ways to do this.  

 

1.  Recommended Way - do it in Power Query.  Group By multiple columns (ID, Customer, and Region) and do a sum on the Revenue column.  This will make it so you only have to load one table into your data model.

 

2. Do it with a DAX table.  With this approach, you'll end up with two tables in your data model.  You can ignore the primary table in your analysis, but it will take up filespace.  Click on New Table on the Modelling tab and enter this expression

 

SummaryTable = ADDCOLUMNS(SUMMARIZE(Table, Table[ID], Table[Customer], Table[Region]), "Revenue", Calculate(Sum(Table[Revenue]))) //replace Table with your actual table name

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.