Forum Discussion
switch using date ranges
I have a DATE table with the following columns
Date (DATE format), (the following columns are all Whole Numbers) WeekNum, Month, Day, Year, Qtr, End Date (DATE format), SprintNumber (whole number) (this is a calculated column I'm using the SWITCH function in)
I'm trying to put a number from 1-8 in this SprintNumber column
SprintNumber 1 = dates between 8/1/2019 and 10/31/2019
SprintNumber 2 = dates between 11/1/2019 and 1/31/2020
SprintNumber 3 = dates between 2/1/2020 and 4/31/2020
SprintNumber 4,5,6,7,8 every 3 months following sprint3
I have the following formula and don't know what I'm doing wrong (I only have the first 3 sprints, but would add 4-8)
12 Replies
- amitchandakSuper User
Anonymous , Formula seems fine. The only doubt I have is that either Month of year is of data type text.
Can you share a sample pbix after removing sensitive data?
- AnonymousNot applicable
I can't send the pbix. However here is a screen shot - YEAR is the same type.
I have also tried this
- amitchandakSuper User
Anonymous , do not use MAX as this column max will take max date. Also, remove values
like
Switch(true(),
Date[Month] = 8 && Date[Year] =2009 , 1,
Date[Month] = 11 && Date[Year] =2009 , 2
)
Also in case you trying some custom financial calendar refer my blog
- AnonymousNot applicable
Here is the DATE table - how I created it.
- AnonymousNot applicable
I didn't get any errors using this (I changed the way the calendar table was created - using
Date Table = CALENDAR(Date (2018, 1, 1), DATE( 2022, 12, 31))Then I used this method: BUT I didn't get ANY results.
- GeradavResponsive Resident
Anonymous The FORMAT() function "Converts a value to text according to the specified format." (Source FORMAT function (DAX) - DAX | Microsoft Docs)
Therefore you would be comparing a number to a text data type.
Also, passing a number as text data type as argument to the VALUE() function is the same as just writing a literal number.
I agree with amitchandak that if you have some sample PBIX that you can share with us, it would help in the process of helping you.David
- AnonymousNot applicable
Geradav Thanks for your help on this. Please see my most recent update. I have cleaned up the function. But I'm not getting the results for sprintnumber 2, or 4.
Thanks in advance,
Jim