Forum Discussion
SWITCH Function for Duration values
Here's my reply
Hi Jihwan_Kim
Thank you for getting back to me 🙂 Sorry if I haven't explained this well.
I am just trying to get something like the below, but using tduration conditions such as, "if greater than 15 minutes...". The below example is something I used to label locations based on postcodes:
London_Group = SWITCH(TRUE(),
LEFT(V_LOCATIONS[Post Code],2)="WD","Greater London",
LEFT(V_LOCATIONS[Post Code],2)="EN","Greater London",
LEFT(V_LOCATIONS[Post Code],2)="HA","Greater London",
LEFT(V_LOCATIONS[Post Code],2)="NW","Greater London",
LEFT(V_LOCATIONS[Post Code],2)="IG","Greater London",
LEFT(V_LOCATIONS[Post Code],2)="BR","Greater London",
LEFT(V_LOCATIONS[Post Code],2)="NE","Non-Greater London",
LEFT(V_LOCATIONS[Post Code],2)="WN","Non-Greater London",
LEFT(V_LOCATIONS[Post Code],2)="WF","Non-Greater London",
LEFT(V_LOCATIONS[Post Code],2)="WA","Non-Greater London",
"Non-Greater London")
What I'm trying to do is write a SWITCH DAX like the above, to label my durations column.
I've tried something like this, but it won't work with the type as duration or with the colons:
Duration_Group = SWITCH(TRUE(),
[duration]<= 0.0:15:00, "0 - 15 Minutes",
[duration]> 0.0:15:00 & <=30, "16-30 Minutes",
Hope this helps explain it a bit better! 🙂
Thanks,
Helen
- Jihwan_Kim5 years agoSuper User
Hi, HelenBrunyee
Thank you for your feedback.
Can you share your sample pbix file?
I understand that you do not need extra grouping table, am I correct?
I think it is an issue with how to write DAX measure, but please kindly share your sample pbix file's link here, then I can try to come up with a more accurate measure.
Thanks.