Forum Discussion
LizardBoi
5 years agoRegular Visitor
Assign text depending on Date
Hi All Im looking for some help in creating a column in my date table that will allocate the season the date is in. I need the information to be created regardless of year - but to include the year...
- 5 years ago
Hey LizardBoi ,
yes, you can do that with a calculated column. Try the following approach:
Season = VAR vMonth = MONTH(myDateTable[Date]) VAR vYear = YEAR(myDateTable[Date]) RETURN SWITCH( TRUE(), vMonth >= 5 && vMonth <= 10, "S" & RIGHT(vYear, 2), vMonth <= 4, "W" & RIGHT(vYear-1, 2) &" /" & RIGHT(vYear, 2), vMonth >= 11, "W" & RIGHT(vYear, 2) & "/" & RIGHT(vYear+1, 2) )If you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic
selimovd
Most Valuable Professional
5 years agoHey LizardBoi ,
yes, you can do that with a calculated column. Try the following approach:
Season =
VAR vMonth = MONTH(myDateTable[Date])
VAR vYear = YEAR(myDateTable[Date])
RETURN
SWITCH(
TRUE(),
vMonth >= 5 && vMonth <= 10, "S" & RIGHT(vYear, 2),
vMonth <= 4, "W" & RIGHT(vYear-1, 2) &" /" & RIGHT(vYear, 2),
vMonth >= 11, "W" & RIGHT(vYear, 2) & "/" & RIGHT(vYear+1, 2)
)
If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
Best regards
Denis
Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic
- LizardBoi5 years agoRegular Visitor
Excellent - Thank you this worked a treat