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
RumSwift
Regular Visitor

Divide the "total" of one field in one table by the "total" of the same field in another table

Hello,

 

I'm new to PowerBI and my Google skills seem to have failed me on this one, so apoligies if I'm missing an answer for this on another thread.

 

Baically, I have two tables in my report Table 1 and Table 2:

tbale1 table2.PNG

 

 

 

 

 

 

 

 

 

 

 

Table 1 contains all of rows for "Cake Type" and a sum of cakes for each called "Sum of cake type". Table 2 contains 2 specific cake types and their sums.

 

In a nutshell, I want to be table to take the Totals of both tables and convert them into a percentage to say "Cake types 4 & 7 make up 12.82% of the total cakes. I want to do it this way as cake types can be added & removed at any point and we may change the cake types in Table 2 as well.

 

Is this possible? Is there an easier way to do this? 

 

P.s - This isn't actually for cake types. I just figured I should change the actual data as it's work related. 

1 ACCEPTED SOLUTION
bcdobbs
Super User
Super User

Have a look at the example I've uploaded: Cake Example 

 

There is a single data table:

 

bcdobbs_1-1639163234217.png

 

 

It uses "Edit Interactions" 

bcdobbs_0-1639163105710.png

To turn of interaction on one table visual.


It then has the following two measures:

 

Sum of Cake Value = SUM ( Cake[Cake Value] )

% of Total Value = 
    DIVIDE (
        [Sum of Cake Value],
        CALCULATE (
            [Sum of Cake Value],
            REMOVEFILTERS(Cake)
        )
    )

 Resulting in this:

 

bcdobbs_2-1639163267726.png

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

2 REPLIES 2
bcdobbs
Super User
Super User

Have a look at the example I've uploaded: Cake Example 

 

There is a single data table:

 

bcdobbs_1-1639163234217.png

 

 

It uses "Edit Interactions" 

bcdobbs_0-1639163105710.png

To turn of interaction on one table visual.


It then has the following two measures:

 

Sum of Cake Value = SUM ( Cake[Cake Value] )

% of Total Value = 
    DIVIDE (
        [Sum of Cake Value],
        CALCULATE (
            [Sum of Cake Value],
            REMOVEFILTERS(Cake)
        )
    )

 Resulting in this:

 

bcdobbs_2-1639163267726.png

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
ValtteriN
Super User
Super User

Hi,

Here is one way to do this.

Example data:

ValtteriN_0-1639138393426.png

I made a Summarized table out of this for my specific cake types 1 and 4.

 

Cake Sums = SUMMARIZE(filter(Cakes,Cakes[Cakes] in {"T1","T4"}),Cakes[Cakes],"Sum",SUM(Cakes[Sums]))
 
Since you already have the table 2 you don't need to do this.

Measures:
Cake Total = CALCULATE(SUM(Cakes[Sums]),ALL(Cakes)) //All cakes
Summarized total = CALCULATE(SUM('Cake sums'[Sum]),ALL('Cake Sums')) //sumarized cakes
Cake margin = DIVIDE(Cakes[Summarized total],Cakes[Cake Total]) //Percentage of summarized/all

End result:
ValtteriN_1-1639138944377.png

 

I hope this helps and if it does consider accepting this as a solution!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.

Top Solution Authors