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

Measure with condition IF do not summarize

Hello colleagues!

 

I have a measure that has an IF that checks if the sum of 2 other measures are 0, if they are, it brings the value from a third Measure.

If not, then it brings Zero.

measure.png

 

 

 

It works, however it seems that the IF is applied even for the Total of the measure, so it doesn't bring the Summarization of the valuesmeaseu4.png

 

measeu2.png





















If I change the IF to 1 in the end, it brings 1 as the Sum:
measeu3.png





 

 

 

 

 

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @Anonymous 

The problem you are seeing with the total row is that it has no concept of the rows in the matrix.  It is calculated as if you took the PN field out of your visual.  What you want to do is add a SUMX to your calculation that will force it to iterate over the PN list.

Something along these lines.

No Future Usage =
SUMX (
    VALUES ( YourTable[PN] );
    IF ( [Requirements] + [ReqsBulk] = 0; [Valid Stock Value]; 0 )
)

This will do the base calculation over all the individual PN then sum the result of each of those.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

You can try something like the following, though will need to be sure the table, columns, and measure match up to what you actually have:

=
IF(
    HASONEVALUE(Table[Pin]),
    [No Future Usage],
    SUMX(
        VALUES( TABLE[PIN]),[No Future Usage]
    )
)
jdbuchanan71
Super User
Super User

Hello @Anonymous 

The problem you are seeing with the total row is that it has no concept of the rows in the matrix.  It is calculated as if you took the PN field out of your visual.  What you want to do is add a SUMX to your calculation that will force it to iterate over the PN list.

Something along these lines.

No Future Usage =
SUMX (
    VALUES ( YourTable[PN] );
    IF ( [Requirements] + [ReqsBulk] = 0; [Valid Stock Value]; 0 )
)

This will do the base calculation over all the individual PN then sum the result of each of those.

Anonymous
Not applicable

Awesome! It worked as a charm!

 

Before this, I tried doing it with a CALCULATE but it didn't work:

 

No future usage = CALCULATE([Valid Stock Value];fRequirements[Quantity]=0)

 

Can you spot what is wrong here?

The SUMX turns the measure into an iterator that runs the calculation against the entire table we fed it 

VALUES ( YourTable[PN] )

Then once it has the calculations for that table it sums the amount.  On an individual row the calculation is for a single PN but on the total row it is the sum of that calc on the table we fed in.  If you don't do it as an interator it runs the total against no PN.

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.