How to filter value by exact date in dax?

Viewed 360

I have been struggling with this for a while. I want to write something like this in dax. So essentially I want to get value (used as a multiplier) if date is earlier than 2020-02-25.

var multiplier = IF ( 'D_Date'[date] > Date(2020; 2; 25); 7,5; 7,6)
return DIVIDE (
    CALCULATE ( [Paid hours (h)]; 'D_Company'[CompanyKey] <> 4 );
    CALCULATE ( SUM ( 'D_Date'[workDayFlag] ) * multiplier ) * 1;
    0
)

Measure Paid hours (h) has relation to the date table. The if statement doesn't work (cannot find name 'date', which exists in powerbi/SSAS and in database), but I haven't figured out any other solution.

I feel like this should be an easy task and I am suprised that my if statement doesn't work.

1 Answers

Since its a measure you cant directly use date column in a if statement by this way. Try below code.

var multiplier = IF ( Max('D_Date'[date]) > Date(2020; 2; 25); 7,5; 7,6)
Related