powerbidax

DAX measure: if statement to return a variable as blank based on condition


I have a table like this:

enter image description here

My "Delta" column is a measure I created, looking like this:

 Delta = 
VAR delta = (DIVIDE(
    SUM('Devices Data'[count]),
    'Devices Data'[Count LY])
    -1)

RETURN IF(ISBLANK(SUM('Devices Data'[count])), BLANK(), FORMAT(delta,"Percent"))

I would actually like to set my "delta" variable as BLANK() when "Count LY" is empty. However, my formula doesn't seem to render it properly, even when I'm trying this in the if statement:

BLANK(delta)

Is there a way to display my delta column as empty (blank) when Count LY is empty?

Thank you in advance for your help


Solution

  • You will need to modify your DAX measure, more precisely in the IF statement you will need to test on Count LY column and not on count column. Try the following measure:

    Delta = 
    VAR delta = (DIVIDE(
        SUM('Devices Data'[count]),
        'Devices Data'[Count LY])
        -1)
    
    RETURN IF(ISBLANK('Devices Data'[count LY]), BLANK(), FORMAT(delta,"Percent"))