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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
GWahlers
New Member

Using IF statement in Measure on group sum

I am using a measure with an if-clause on a matrix visual. The values within the subdimension are correct but not on the parent dimension. The if -statement even affects the row sum, instead of summing all child values up. What am i doing wrong?

 

Problem.png

2 REPLIES 2
GWahlers
New Member

Hi Liu Yang,
but if i try changing the "Group" to "Zip Code" or "Country" the values will be wrong. Is it a bug, or why does power bi apply the if condition even on the summarizing rows? 

Kind Regards, 
Gerrit Wahlers

Anonymous
Not applicable

Hi  @GWahlers ,

I created some data:

vyangliumsft_0-1682301747806.png

In the matrix, you can use IF+ ISINSCOPE() to determine the different levels.

ISINSCOPE function (DAX) - DAX | Microsoft Learn

 

Here are the steps you can follow:

1. Create measure.

Flag =
IF(      
        ISINSCOPE('Table'[Group2]),
        SUMX(
            FILTER(ALL('Table'),
            'Table'[Group1]=MAX('Table'[Group1])&&'Table'[Group2]=MAX('Table'[Group2])),[Measure])
        ,
IF(
    ISINSCOPE('Table'[Group1]),
    SUMX(
          FILTER(ALL('Table'),
            'Table'[Group1]=MAX('Table'[Group1])),[Measure])
    ,       
        SUMX(ALL('Table'),[Measure])      
        ))

2. Result:

vyangliumsft_1-1682301747808.png

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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