Forum Discussion

h4tt3n's avatar
h4tt3n
Icon for Helper V rankHelper V
5 years ago
Solved

Problems with graph showing timestamped data, can't use working calendar as x axis.

Hello  everyone,

 

I am working professionally with processing and visualizing timestamped sensor data, like temperature and power. For that purpose, I have built a DAX calendar table with date and time for use as the x axis in graphs and for a time slicer.

 

However, when consuming data from a certain API, I simply can't make PBI show data or do time slicing using my trusted method. I have spent hours and hours trying to pinpoint the problem, but I'm at my wits end and hope for some useful feedback from you people.

 

When visualizing data using the data table timestamps as x axis, there is no problem:

 

 

But when I replace the timestamp column with my own datetime column, nothing is shown:

 

 

 

Here is the DAX code for my calendar:

 

 

 

CalendarDate = //

ADDCOLUMNS 
(
    //calendarauto(1),
    CALENDAR( min( 'Tagsdata Between'[d] ), max( 'Tagsdata Between'[d] ) ),
    "Year", YEAR ( [Date] ),
    "QuarterOfYear", Quarter ( [Date] ),
    "MonthOfYear", MONTH( [Date] ),
    "WeekOfYear", WEEKNUM( [Date], 1 ),
    "DayOfMonth", DAY( [Date] ),
    "DayOfWeek", WEEKDAY ( [Date] ),
    "DayName",  FORMAT ( [Date], "dddd" ),
    "MonthName",  FORMAT ( [Date], "mmmm" ),
    "IsWorkingDay", NOT WEEKDAY( [Date] ) IN { 1,7 }
)
CalendarTime = //

VAR HourTable    = SELECTCOLUMNS( GENERATESERIES( 0, 23 ), "Hour",   [Value] )
VAR MinuteTable  = SELECTCOLUMNS( GENERATESERIES( 0, 59 ), "Minute", [Value] )
VAR SecondsTable = SELECTCOLUMNS( GENERATESERIES( 0, 59 ), "Second", [Value] )

RETURN
 
ADDCOLUMNS
(
    //CROSSJOIN( HourTable, MinuteTable, SecondsTable ),
    CROSSJOIN( HourTable, MinuteTable ),

    //"Time", TIME( [Hour], [Minute], [Second] )
    "Time", TIME( [Hour], [Minute], 0 )
)
CalendarDateTime = //

ADDCOLUMNS
( 
    CROSSJOIN( 'CalendarDate' , 'CalendarTime' ),
    "DateTime", 'CalendarDate'[Date] + 'CalendarTime'[Time]
)

 

 

 

 

Screenshot of CalendarDateTime:

 

 

Screenshot of relations:

 

 

 

Here is the raw output from the API that I'm having trouble with ("d" is timestamp and "v" is sensor value):

{"d":"2020-08-25T21:27:50.298Z","v":0.002}

 

I have tried changing the formatting, and both included and excluded seconds in my calendar table. 

 

In the M Power Query all relevant columns are casted to type datetime.

 

What am I overlooking?

 

Cheers & have a nice weekend,

Mike

 

  • Hi, h4tt3n 

     

    It’s my pleasure to answer for you.

    According to your description,I think the calendar table may be no problem.But,your data has millisecond, Although they are  datetime types, they can't match,so it doesn't show up.You can try to extract the year, month, day,hour,minute and second from the original data in PQ to reconstruct a datetime,then create relationships.

    If it doesn’t solve your problem, please feel free to ask me.

     

    Best Regards

    Janey Guo

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • v-janeyg-msft's avatar
    v-janeyg-msft
    Icon for Community Support rankCommunity Support

    Hi, h4tt3n 

     

    It’s my pleasure to answer for you.

    According to your description,I think the calendar table may be no problem.But,your data has millisecond, Although they are  datetime types, they can't match,so it doesn't show up.You can try to extract the year, month, day,hour,minute and second from the original data in PQ to reconstruct a datetime,then create relationships.

    If it doesn’t solve your problem, please feel free to ask me.

     

    Best Regards

    Janey Guo

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Thanks alot for sharing your DAX code and showing the relationships between your sensor data and the created calendar. This thread helped me big time plotting sensor data over time with a nice slicer for date