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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
azura
Frequent Visitor

How to create subtotals as new row from multiple id

dear all

 

I currently have some problems to create subtotal as new row and create total from subtotal as new row. I have multiple IDs with a full row with different id.

here is my table and the expected output

https://drive.google.com/open?id=1Mk-GKsXgmJMTPeUtXNUloBK5FeIcNPKd

 

how i can do that in power BI,

thank you in advance 

 

azura

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @azura ,

 

To createa some calculated tables as below.

 

mixd = SUMMARIZECOLUMNS(Table1[Year],"Productid",MAX(Table1[Productid]),"productname","mixd","amount",SUM(Table1[amount]))
fruits = SUMMARIZECOLUMNS(Table1[Year],"Productid",MAX(Table1[Productid]),"Productname","Fruits","amount",CALCULATE(SUM(Table1[amount]),FILTER(Table1,Table1[producename]="apple" || Table1[producename]="banana")))
vagetables = SUMMARIZECOLUMNS(Table1[Year],"Productid",MAX(Table1[Productid]),"Productname","vegaables","amount",CALCULATE(SUM(Table1[amount]),FILTER(Table1,Table1[producename]="tomatoes" || Table1[producename]="brocoli"))) 
Table = UNION(Table1,mixd,fruits,vagetables)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @azura ,

 

To createa some calculated tables as below.

 

mixd = SUMMARIZECOLUMNS(Table1[Year],"Productid",MAX(Table1[Productid]),"productname","mixd","amount",SUM(Table1[amount]))
fruits = SUMMARIZECOLUMNS(Table1[Year],"Productid",MAX(Table1[Productid]),"Productname","Fruits","amount",CALCULATE(SUM(Table1[amount]),FILTER(Table1,Table1[producename]="apple" || Table1[producename]="banana")))
vagetables = SUMMARIZECOLUMNS(Table1[Year],"Productid",MAX(Table1[Productid]),"Productname","vegaables","amount",CALCULATE(SUM(Table1[amount]),FILTER(Table1,Table1[producename]="tomatoes" || Table1[producename]="brocoli"))) 
Table = UNION(Table1,mixd,fruits,vagetables)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi Frank;

 

thanks for your response, the real dataset more complex than the sample, currently i'am on going prosess to solved this with your guidace, i got the idea, and it worked in my dataset;

 

but i missed some calculation, like subrtraction; ( sub Mixed )

is it possible to subtracted fruit - vegetables;

i tried to create table which group by and amount is calculated filter fruit - calculated filter vegetables  But Got Error;

 

Sub Mixed = SUMMARIZECOLUMNS(Table1[Year],"Productid",MAX(Table1[Productid]),"Productname","Fruits","amount",CALCULATE(SUM(Table1[amount]),FILTER(Table1,Table1[producename]="apple" || Table1[producename]="banana") - CALCULATE(SUM(Table1[amount]),FILTER(Table1,Table1[producename]="brocoli" || Table1[producename]="tomatoes"))))

 

best regards;

 

Azura

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors