Forum Discussion
switch using date ranges
Start with the highest month number first like this:
SprintNumberTM
SWITCH ( TRUE(),
'Date Table'[Month] > 11 && 'Date Table'[Year] - 2019, 2,
'Date Table'[Month] > 8 && 'Date Table'[Year] - 2019, 1,
'Date Table'[Month] > 4 && 'Date Table' [Year] - 2020, 4,
'Date Table'[Month] > 1 && 'Date Table'[Year] 2020, 3
)
In your case, if you start evaluating a month number greater than or equal to 8 when the function checks whether month 12 is greater than 8, it returns TRUE(), and therefore stops the SWITCH() evaluation and returns a value of 1, and does not go to the second evaluation statement.
If you start with the highest number, the function first checks whether the month number is greater than or equal to 11, if you do not continue with the second evaluation statement.
E.g.
•> Is month 5 greater than or equal to 11 --> False (continue with the following eval statement)
•> Is month 5 greater than or equal to 8 --> False (continue with the following eval statement)
•> Is month 5 greater than or equal to 4 --> True (stops evaluation)
•> Returns 4
Does it make sense?
I hope that helps. Let us know
David
I found this solution which is working correctly -
Thank you for your responses to help me figure this out!
Jim