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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Reetz
Helper II
Helper II

% calculation not correct in totals

Capture.PNG

 

Not sure if this is even possible. 

My measure:

Usage %=IFERROR (IF( product 1>0, DIVIDE ( product 2, product 1) ,0), " - " )

 

My 2 issues are: 

1.  if product 1 =0 and product 2 >0, I want to show product 2 at the row level, but not have it included in the total.  

2.  for the Usage % in the Total line,  i want to include only those accounts that have Product 1 orders >0 and Product 2 orders >=0.  (The calculation would be 40/95=42.1%)

 

Thanks in advance!

1 REPLY 1
sturlaws
Resident Rockstar
Resident Rockstar

Hi @Reetz 

 

in your screenshot line two changes from 12 to 40. I assume this is a typo.

You can use this dax to solve it:

 

usage % =
VAR _tmp =
    DIVIDE (
        SUMX ( someTable, IF ( someTable[Prod1] > 0, someTable[Prod2], 0 ) ) + 0,
        SUMX ( someTable, IF ( someTable[Prod1] > 0, someTable[Prod1], 0 ) )
    )
RETURN
    IF ( ISBLANK ( _tmp ), "-", _tmp )

 

 

As for the product 2-column, this has to be converted to a measure to achieve the desired output:

Measure Prod 2 =
IF (
    HASONEVALUE ( someTable[Prod2] ),
    SUM ( someTable[Prod2] ),
    CALCULATE (
        SUM ( someTable[Prod2] ),
        VAR _tmp =
            CALCULATETABLE (
                VALUES ( someTable[Act] ),
                FILTER ( someTable, someTable[Prod2] > 0 && someTable[Prod1] > 0 )
            )
        RETURN
            FILTER ( someTable, someTable[Act] IN _tmp )
    )
)

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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