Forum Discussion

msimmonsmcse's avatar
msimmonsmcse
Helper I
5 years ago

Trouble with date comparison

I am trying to write a measure that will calculate the number of business days in a given period of time. I have a date table that starts at 1/1/2019 and ends on 12/31/2020. Here is my measure:

 
Count of Business Days =
var StartDate = MIN('Date'[Date])
var EndDate = IF(MAX('Date'[Date])>TODAY()-1, TODAY()-1, MAX('Date'[Date])
RETURN
 
StartDate will return: 1/1/2019
EndDate returns: 44117 (sets data type to Decimal).
If I change the data type to Date, I get: dddd MMMM d yyyy
 
Why is it not returning the value of TODAY()-1? If I set the variable to only return TODAY()-1, it returns yesterdays date correctly

2 Replies