Do a flag (1 or 0) using DAX Powerbi

Viewed 123

I am new to DAX and i want to do a flag based on the time

the flag column is called "New", to determine whether is it new, Value YTD >0 and Value YTD Past Year is 0 or blank

my table

period | product | value YTD | value YTD Past Year |
202201 | Apple | 1000 | 0
202201 | Orange | 1000 | 0
202201 | Durian | 2033 | 100

output table

period | product | value YTD | value YTD Past Year | New 
202201 | Apple | 1000 | 0 | 1
202201 | Orange | 1000 | 0 | 1
202201 | Durian | 2033 | 100 | 0

Any help is appreciated!

1 Answers

My understanding is that you have three cases :

Value YTD Value YTD Past Year Output
>0 >0 0
>0 0 1
0 0 BLANK

Then, you should be able to create the new calculated column New as

New =
SWITCH(
    TRUE(),
    [Value YTD] > 0 && [Value YTD Past Year] > 0,
    0,
    [Value YTD] > 0 && [Value YTD Past Year] = 0,
    1,
    BLANK()
)
Related