Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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:

 

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

 

  • 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
    )
    

1 Reply

  • 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
    )