Forum Discussion

villasenorbritt's avatar
villasenorbritt
Resolver I
4 years ago
Solved

Changing Column to Two Groups

I have a column that has numbers from 0-23 to represent the hours in the day. I am wanting to split these hours into a "AM shift" and a "PM shift" but can not figure out how. Can someone please post ...
  • mahenkj2's avatar
    4 years ago

    Hi villasenorbritt ,

    If this hour in fact table, then don't make any change in this table. Just create a Dimension table with shift timing and make a realtionship with Hour of dim table with your fact table with Hour columns. Advantage of this is, you have more control on slicing and filtering of the data in your report.

     

    To make a dim table, I would suggest that at first prepare it in excel as below:

    HourShiftShiftTime
    0PM5PM-5AM
    1PM5PM-5AM
    2PM5PM-5AM
    3PM5PM-5AM
    4PM5PM-5AM
    5AM5AM-5PM
    6AM5AM-5PM
    7AM5AM-5PM
    8AM5AM-5PM
    9AM5AM-5PM
    10AM5AM-5PM
    11AM5AM-5PM
    12AM5AM-5PM
    13AM5AM-5PM
    14AM5AM-5PM
    15AM5AM-5PM
    16AM5AM-5PM
    17AM5AM-5PM
    18PM5PM-5AM
    19PM5PM-5AM
    20PM5PM-5AM
    21PM5PM-5AM
    22PM5PM-5AM
    23PM5PM-5AM
    24PM5PM-5AM

     

    Why, because this is a kind of fixed table, and should not change so often.

     

    Then copy it. Ctrl+C

     

    In power BI use enter data to paste this table:

     

    Paste as below and create a new dim Shift table:

     

     

    Now just relate hour of this table with fact table's hour column with 1 to many relationship.

     

    Use dim table columns as slicers in your visuals.

     

    Hope it helps.