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
AWF14978
Frequent Visitor

IF Measure not totaling correctly and adding incorrect segments

Hi, I'm having trouble with the below table... and specifically with the 'Turned on' Measure:

AWF14978_0-1674480488459.png

 

Turned_on = 
var Interval = CALCULATE([Das_orders],General[Performance Section[Performance Section]]] = "Interval")
var Interval_blank = IF(Interval = 0,1,0)

return

SUMX(General, Interval_blank)

 

Firstly, how do I get the grand total to appear? and how do I produce the measure to only count the 1 performance section, IE

the grand total for the first row should be 3 as there are 3 intervals = 0 but its summing all interval sections?

 

Thank you!!

 

AF

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

DAX variables are really constants, only calculated when they are declared, so I think you need to move the variables inside the SUMX iteration

Turned_on =
SUMX (
    General,
    VAR Interval =
        CALCULATE (
            [Das_orders],
            General[Performance Section[Performance Section]]] = "Interval"
        )
    VAR Interval_blank =
        IF ( Interval = 0, 1, 0 )
    RETURN
        Interval_blank
)

View solution in original post

1 REPLY 1
johnt75
Super User
Super User

DAX variables are really constants, only calculated when they are declared, so I think you need to move the variables inside the SUMX iteration

Turned_on =
SUMX (
    General,
    VAR Interval =
        CALCULATE (
            [Das_orders],
            General[Performance Section[Performance Section]]] = "Interval"
        )
    VAR Interval_blank =
        IF ( Interval = 0, 1, 0 )
    RETURN
        Interval_blank
)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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