Forum Discussion
switch using date ranges
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
amitchandak Thank you - I cleaned it up a bit. Its not seeing the second line where month = 11 and month = 4. Its only giving results as Sprintnumber 1 and sprint number 3. When month = 11 or greater, it doesn't give the result sprintnumber 2
- Geradav5 years agoResponsive Resident
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
- Anonymous5 years agoNot applicable
Hi David - thanks for your help! It does, however I'm using an AND - not OR- won't it evaluate the entire line?
Thanks,
Jim
- Anonymous5 years agoNot applicable
I found this solution which is working correctly -
Thank you for your responses to help me figure this out!
Jim