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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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