Forum Discussion
michael_knight
6 years agoPost Prodigy
IF Statement measure with Time
Hi, I'm trying to recreate a Conditional Column I've got on another report but as a DAX measure. I'm unable to replicate it in Power Query so I'm trying to create it in measure form ...
- 6 years ago
Hi Micheal
I feel you would be better using a M query
and look up the time of day with a relationship.
But if you must use a DAX measure then try this solution ….Time of day =
// get a time as scalar vaue
Var mytime = MIN(Times[Time])
// get the hour element of the time
Var myhour= HOUR(mytime)
RETURN
SWITCH(
TRUE(),
myhour < 11, "Morning",
myhour < 14, "Afternoon",
myhour < 17, "Late Afternoon",
myhour < 20, "Evening",
BLANK()
)
The big draw back of this soultion is that DAX measures need a scalar, which is why a M query and lookup might be a better solution.
camargos88
6 years agoCommunity Champion