Forum Discussion

tmears's avatar
tmears
Helper III
8 years ago
Solved

IF statement maybe?

  Hi all   I have a problem wondering if anyone could make any suggestions or help??  I have the following calcuated column:   FirstDayEndTime = DATE ( YEAR ( incident[createdon] ), MONTH ( i...
  • vcastello's avatar
    8 years ago

    Hi tmears

     

    From my point of view ...

    if you know and can assign to each customer a range hour.

    Let's say all the customers that end their hours at 17:00 could be assigned 'Type A', and all those that end their hours at 18:00 could be assigned 'Type B'

    Then you could use ....

    FirstDayEndTime =
    IF(
        Customers[Type] = "Type A",
        DATE ( YEAR ( incident[createdon] ), MONTH ( incident[createdon]  ), DAY ( incident[createdon]  ) )

         & " 17:00:00",
        DATE ( YEAR ( incident[createdon] ), MONTH ( incident[createdon]  ), DAY ( incident[createdon]  ) )
        & " 18:00:00"
    )

    Hope That Helps

    Vicente

  • v-ljerr-msft's avatar
    v-ljerr-msft
    8 years ago

    Hi tmears,

     

    In addition, using SWITCH function should also work. :smileyhappy:

    FirstDayEndTime =
    SWITCH (
        Customers[Type],
        "Type A", DATE ( YEAR ( incident[createdon] ), MONTH ( incident[createdon] ), DAY ( incident[createdon] ) )
            & " 17:00:00",
        "Type B", DATE ( YEAR ( incident[createdon] ), MONTH ( incident[createdon] ), DAY ( incident[createdon] ) )
            & " 18:00:00",
        "Type C", DATE ( YEAR ( incident[createdon] ), MONTH ( incident[createdon] ), DAY ( incident[createdon] ) )
            & " 19:00:00",
        "Type D", DATE ( YEAR ( incident[createdon] ), MONTH ( incident[createdon] ), DAY ( incident[createdon] ) )
            & " 20:00:00"
    )
    

     

    Regards