Forum Discussion

ksmith0411's avatar
ksmith0411
Regular Visitor
4 years ago
Solved

Switch function

Hi,   Im trying to do a swicth query between two times ie if Start time >=08:00:00 & End time <=09:00:00 then return 09:00:00 but im not having any joy   If anyone can help that woul dbe great. ...
  • v-yingjl's avatar
    4 years ago

    Hi ksmith0411 ,

    Whether you need to save the first row as variable which named 'Hour_Part' and create the calculated column like this:

    Column 2 =
    VAR Hour_Part =
        TIME ( HOUR ( Actual[Start Time] ), MINUTE ( Actual[Start Time] ), SECOND ( Actual[Start Time] ) )
    RETURN
        SWITCH (
            TRUE (),
            Hour_Part > TIME ( 8, 0, 0 )
                && Hour_Part < TIME ( 9, 0, 0 ), TIME ( 9, 0, 0 )
        )
    

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.