Search code examples
powerbipowerbi-desktoppowerbi-datasourcepower-bi-report-serverpowerbi-custom-visuals

How to convert HOUR to Between BETWEEN_HOUR in Power BI?


I have table HOUR Column

HOUR
1
2
3

Like this but we need to convert into

BETWEEN_HOUR
01:00 - 02:00
02:00 - 03:00
03:00 - 04:00

How to achieve the same


Solution

  • We can use advanced editor and custom column to use conditional rule to derive the condition.

    if [HOUR] = 24 then "00:00 - 01:00"
    else if [HOUR] = 25 then "01:00 - 02:00"
    else if [HOUR] = 26 then "02:00 - 03:00"
    else if [HOUR] = 27 then "03:00 - 04:00"
    else if [HOUR] = 28 then "04:00 - 05:00"
    else if [HOUR] = 29 then "05:00 - 06:00"
    else if [HOUR] = 30 then "06:00 - 07:00"
    else if [HOUR] = 31 then "07:00 - 08:00"
    else if [HOUR] = 8 then "08:00 - 09:00"
    else if [HOUR] = 9 then "09:00 - 10:00"
    else if [HOUR] = 10 then "10:00 - 11:00"
    else if [HOUR] = 11 then "11:00 - 12:00"
    else if [HOUR] = 12 then "12:00 - 13:00"
    else if [HOUR] = 13 then "13:00 - 14:00"
    else if [HOUR] = 14 then "14:00 - 15:00"
    else if [HOUR] = 15 then "15:00 - 16:00"
    else if [HOUR] = 16 then "16:00 - 17:00"
    else if [HOUR] = 17 then "17:00 - 18:00" |
    else if [HOUR] = 18 then "18:00 - 19:00"
    else if [HOUR] = 19 then "19:00 - 20:00"
    else if [HOUR] = 20 then "20:00 - 21:00"
    else if [HOUR] = 21 then "21:00 - 22:00"
    else if [HOUR] = 22 then "22:00 - 23:00"
    else if [HOUR] = 23 then "23:00 - 24:00"
    else null
    

    Result:

    enter image description here