Forum Discussion
New calculated column with IF/Switch function where data are from Time formated Column
Hi
I have a 24h time column where I want to classify each row into a new column.
My time column looks like 01:33 etc and is formated as Time
NewColumn =
if('data'[Time]<=07:00 && 'data'[Time]>=17:30, "A"),
if('data'[Time]<=06:00 && 'data'[Time]>=07:00, && 'data'[Time]<=17:30 && 'data'[Time]>=22:00, "B"),
also would like to have all other time values into "C"
11 Replies
- cs_skitResolver IV
Don't you have the solution already?
Use
NewColumn =
SWITCH(TRUE();
expression1;"A";
expression2;"B";
"C")
- BSXSFrequent Visitor
Iam gettin C in all rows with this;
NewColumn =
SWITCH(TRUE();
'data'[Time]<=0700 && 'data'[Time]>=1730;"A";
'data'[Time]<=0600 && 'data'[Time]>=0659 && 'data'[Time]<=1730 && 'data'[Time]>=2159;"B";
"C")The column is time formatted and look like 14:33
- cs_skitResolver IV
if you get all C your filter expressions are wrong for A and B because they return 0 rows
you can also test your expressions seperately with some rowcount filter measures if they are correct
- AleResolver II
Not sure if this was solved or not, but:
-
NewColumn =
if('data'[Time]<=07:00 && 'data'[Time]>=17:30, "A"),
if('data'[Time]<=06:00 && 'data'[Time]>=07:00, && 'data'[Time]<=17:30 && 'data'[Time]>=22:00, "B"),
also would like to have all other time values into "C"
-
It's impossible for any time be smaller than 7:00 and bigger than 17:30. that's why you get alwasy C.