Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Need Help with Calendar Table

I am trying to build a new calandar table in my Power BI app. I fiund this suggestion, which gives me the attributes I am looking for except the time is coming up as 1899 and 8 AM is missing.

 

Any suggestions?

 

DateTime =
ADDCOLUMNS (
CROSSJOIN (
CALENDAR ( DATE ( 2018, 1, 1 ), DATE ( 2025, 12, 31 ) ),
UNION (
ROW ( "Time", TIME ( 1, 0, 0 ) ),
ROW ( "Time", TIME ( 2, 0, 0 ) ),
ROW ( "Time", TIME ( 3, 0, 0 ) ),
ROW ( "Time", TIME ( 4, 0, 0 ) ),
ROW ( "Time", TIME ( 5, 0, 0 ) ),
ROW ( "Time", TIME ( 6, 0, 0 ) ),
ROW ( "Time", TIME ( 7, 0, 0 ) ),
ROW ( "Time", TIME ( 9, 0, 0 ) ),
ROW ( "Time", TIME ( 10, 0, 0 ) ),
ROW ( "Time", TIME ( 11, 0, 0 ) ),
ROW ( "Time", TIME ( 12, 0, 0 ) ),
ROW ( "Time", TIME ( 13, 0, 0 ) ),
ROW ( "Time", TIME ( 14, 0, 0 ) ),
ROW ( "Time", TIME ( 15, 0, 0 ) ),
ROW ( "Time", TIME ( 16, 0, 0 ) ),
ROW ( "Time", TIME ( 17, 0, 0 ) ),
ROW ( "Time", TIME ( 18, 0, 0 ) ),
ROW ( "Time", TIME ( 19, 0, 0 ) ),
ROW ( "Time", TIME ( 20, 0, 0 ) ),
ROW ( "Time", TIME ( 21, 0, 0 ) ),
ROW ( "Time", TIME ( 22, 0, 0 ) ),
ROW ( "Time", TIME ( 23, 0, 0 ) ),
ROW ( "Time", TIME ( 24, 0, 0 ) )
)
),
"DateTime", [Date] + [Time],
"Hour", HOUR ( [Time] )
)

  • v-frfei-msft's avatar
    v-frfei-msft
    7 years ago

    Hi Anonymous,

     

    Change the data type to time.

     

     

    Regards,

    Frank

4 Replies

  • jthomson's avatar
    jthomson
    Solution Sage

    I have no idea what the heck you're trying to do with this, but if that is your actual formula then there's a very good reason why 8am is missing...

  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi Anonymous,

     

    I upldated the formula as below, it worked well.

     

    DateTime = 
    ADDCOLUMNS (
    CROSSJOIN (
    CALENDAR ( DATE ( 2018, 1, 1 ), DATE ( 2025, 12, 31 ) ),
    UNION (
    ROW ( "Time", TIME ( 1, 0, 0 ) ),
    ROW ( "Time", TIME ( 2, 0, 0 ) ),
    ROW ( "Time", TIME ( 3, 0, 0 ) ),
    ROW ( "Time", TIME ( 4, 0, 0 ) ),
    ROW ( "Time", TIME ( 5, 0, 0 ) ),
    ROW ( "Time", TIME ( 6, 0, 0 ) ),
    ROW ( "Time", TIME ( 7, 0, 0 ) ),
    ROW("Time", TIME(8,0,0)),
    ROW ( "Time", TIME ( 9, 0, 0 ) ),
    ROW ( "Time", TIME ( 10, 0, 0 ) ),
    ROW ( "Time", TIME ( 11, 0, 0 ) ),
    ROW ( "Time", TIME ( 12, 0, 0 ) ),
    ROW ( "Time", TIME ( 13, 0, 0 ) ),
    ROW ( "Time", TIME ( 14, 0, 0 ) ),
    ROW ( "Time", TIME ( 15, 0, 0 ) ),
    ROW ( "Time", TIME ( 16, 0, 0 ) ),
    ROW ( "Time", TIME ( 17, 0, 0 ) ),
    ROW ( "Time", TIME ( 18, 0, 0 ) ),
    ROW ( "Time", TIME ( 19, 0, 0 ) ),
    ROW ( "Time", TIME ( 20, 0, 0 ) ),
    ROW ( "Time", TIME ( 21, 0, 0 ) ),
    ROW ( "Time", TIME ( 22, 0, 0 ) ),
    ROW ( "Time", TIME ( 23, 0, 0 ) ),
    ROW ( "Time", TIME ( 24, 0, 0 ) )
    )
    ),
    "DateTime", [Date] + [Time],
    "Hour", HOUR ( [Time] )
    )

    Regards,

    Frank

    • Anonymous's avatar
      Anonymous
      Not applicable

      Frank,

       

      Thanks for getting back to me. After I applied the suggested changes, I see the time column has 1899 dates.

       

       

       

       

    • v-frfei-msft's avatar
      v-frfei-msft
      Community Support

      Hi Anonymous,

       

      Change the data type to time.

       

       

      Regards,

      Frank