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
Anonymous
Not applicable

Showing % totals of categories in Matrix

Hey Everyone,
I am trying to re-create a tableau report on Power BI. In tableau I have a matrix like this (rows: product name, product version; column: os version; values: # of machines, % of machines)

teckchan_0-1622575077778.png

there is just one primary field for values - # of machines. The % of machines here is the % for each "product name". in tableau we have the option to show value as percentage and compute using "pane" where as in Power BI I can only show percentages as row total, column total or grand total. How do I replicate this % calculation in Power BI?

teckchan_1-1622575751890.png

I tried to use a measure to calculate this:

MeasureC =
var Product_name = VALUES('Product Versions'[Product Name])
var Product_version = VALUES('Product Versions'[product_version])
var Machines = SUM('Product Versions'[# of Machines])
var Total_machines =
SWITCH(
TRUE(),
ISINSCOPE('Product Versions'[os_version]),CALCULATE(SUM('Product Versions'[# of Machines]),ALLSELECTED('Product Versions'),'Product Versions'[Product Name] in Product_name,'Product Versions'[product_version] in Product_version),
ISINSCOPE('Product Versions'[product_version]),CALCULATE(SUM('Product Versions'[# of Machines]),ALLSELECTED('Product Versions'),'Product Versions'[Product Name] in Product_name),
ISINSCOPE('Product Versions'[Product Name]),CALCULATE(SUM('Product Versions'[# of Machines]),ALLSELECTED('Product Versions'))
)
return
IF(
ISINSCOPE('Product Versions'[product_version]),
DIVIDE(Machines,Total_machines),
1
)

Here is what my pbi matrix looks like currently (incorrect):

teckchan_2-1622576032167.png

Thanks!

1 ACCEPTED SOLUTION

I think this should do it.

 

MeasureC = 
DIVIDE (
    SUM ( 'Product Versions'[# of Machines] ),
    CALCULATE (
        SUM ( 'Product Versions'[# of Machines] ),
        ALLSELECTED ( 'OS Version Order' ),
        ALLSELECTED ( 'Product Versions'[product_version] )
    )
)

View solution in original post

8 REPLIES 8
AlexisOlson
Super User
Super User

It looks like you want your denominator to be the total for that Product Name. In this case, you don't really need ISINSCOPE.

 

MeasureC =
DIVIDE (
    SUM ( 'Product Versions'[# of Machines] ),
    CALCULATE (
        SUM ( 'Product Versions'[# of Machines] ),
        ALLSELECTED ( 'Product Versions' ),
        ALLEXCEPT ( 'Product Versions', 'Product Versions'[Product Name] )
    )
)
Anonymous
Not applicable

Hey @AlexisOlson ,
Thanks for your reply. Yes, the denominator should be the total for that product name. I tried your measure but I still don't get the correct numbers (PFA image below). I am looking to make the rows showing totals at the product name level "100%" (highlighted cells below) and then the break up by product version. 

teckchan_0-1622590978050.png

 

There's some filter or context that I'm not seeing. Any chance you can share the file or some sample version of it?

Anonymous
Not applicable

Hey @AlexisOlson ,
Sure thing. Here's the link to the sample file on my drive. Please do let me know if you're having any trouble downloading it. Thanks.
Best,
Akash

I think this should do it.

 

MeasureC = 
DIVIDE (
    SUM ( 'Product Versions'[# of Machines] ),
    CALCULATE (
        SUM ( 'Product Versions'[# of Machines] ),
        ALLSELECTED ( 'OS Version Order' ),
        ALLSELECTED ( 'Product Versions'[product_version] )
    )
)
Anonymous
Not applicable

This worked well! thank you so much @AlexisOlson 

Hmm. Are there any tables involved other than 'Product Versions'?

Anonymous
Not applicable

Hey @AlexisOlson ,
Nope. this is the only primary table. I just use another table just to get the OS versions in my desired order

teckchan_0-1622648991604.png

 

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.