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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AI14
Helper III
Helper III

calculate sum of if measure

Hi

 

How can i calculate sum of if measure - atm its adding 1 if true but its not summing total or even if i add to a graph it shows as 1 when it should be 5 for example

 

AI14_0-1676551160084.png

 

1 ACCEPTED SOLUTION

@AI14 
Please let me explain. 

The IF statement measure is non-additive measure. In PowerBi the total cell is evaluated just the same as any other cell (it is NOT the sum of the cells above). In fact the total cell is just another cell with different filter context (or no filter context in case of a table visual total or a matrix's grand total).

Usually non-additive measures are not supposed to be additive such as averages and percentages. For example if I have a measure that calculates the price per unit for different stores ($/unit), summing this measure for different stores to get a total has absolutely no meaning.

However, in your case this total is required and has meaning therefore, we need to force additivity. But forcing additivity depends on the filter context of the visual (the SUMMARIZECOLUMNS table created by power bi when you place the columns in the table visual). We need to manually create this table, iterate over it in order to sum the visible values in the visual.

I still don't have a clear idea about what you have there in the visual and the relationships between the different tables involved however, it would be something like

Duration Breach > =
SUMX (
    SUMMARIZE (
        FactTable,
        DimTable1[Column1],
        DimTable2[Column2],
        DimTable3[Column3]
    ),
    CALCULATE (
        IF (
            SUMX ( CLEAN_LIVE, CLEAN_LIVE[LiveCleanTime] )
                > SUMX ( 'Task Rules', 'Task Rules'[Duration] ),
            1
        )
    )
)

 

 

 

 

View solution in original post

6 REPLIES 6
tamerj1
Super User
Super User

Hi @AI14 
Which measure? Would you please indicate in the screenshot? And which column(s) are used to slice by in this table visual?

Hi

these are measures i created and put in a table.

 

AI14_1-1676557476997.png

 

1st measure:

Duration Breach >= IF(
    SUMX(CLEAN_LIVE,CLEAN_LIVE[LiveCleanTime]) > SUMX('Task Rules','Task Rules'[Duration]), 1)
 
2nd Measure
Duration Breach <= IF(
    SUMX(CLEAN_LIVE,CLEAN_LIVE[LiveCleanTime]) < SUMX('Task Rules','Task Rules'[Duration]), 1)
 
3rd Measure 
Finish Late =
IF ( [Finish-STD] > SUMX ( 'Task Rules', 'Task Rules'[Latest End] ), 1 )
 
4th Measure:
Duration+Late = IF(AND(
    [Duration Breach >] = 1 , [Finish Late] = 1),2)
 
These Measures add a 1 or 2 (4th measure) if statement true however its not summing.

@AI14 

Thank you

at the very right of the table you have a column [Start of H.... apparently you have other columns to the left, whatare they? From which tables? Whare the relationships between the tables?

using 3 different tables all have active relationships, either 1-2-many or many-2-many, the rest are measures.

 

the calculations are correct and the measures are working correctly but not counting the amount of times the statement is true

@AI14 
Please let me explain. 

The IF statement measure is non-additive measure. In PowerBi the total cell is evaluated just the same as any other cell (it is NOT the sum of the cells above). In fact the total cell is just another cell with different filter context (or no filter context in case of a table visual total or a matrix's grand total).

Usually non-additive measures are not supposed to be additive such as averages and percentages. For example if I have a measure that calculates the price per unit for different stores ($/unit), summing this measure for different stores to get a total has absolutely no meaning.

However, in your case this total is required and has meaning therefore, we need to force additivity. But forcing additivity depends on the filter context of the visual (the SUMMARIZECOLUMNS table created by power bi when you place the columns in the table visual). We need to manually create this table, iterate over it in order to sum the visible values in the visual.

I still don't have a clear idea about what you have there in the visual and the relationships between the different tables involved however, it would be something like

Duration Breach > =
SUMX (
    SUMMARIZE (
        FactTable,
        DimTable1[Column1],
        DimTable2[Column2],
        DimTable3[Column3]
    ),
    CALCULATE (
        IF (
            SUMX ( CLEAN_LIVE, CLEAN_LIVE[LiveCleanTime] )
                > SUMX ( 'Task Rules', 'Task Rules'[Duration] ),
            1
        )
    )
)

 

 

 

 

Amazing, Works like a charm !!

 

thanks for the explanation too, made alot of difference👍

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.