Forum Discussion

CalleWagenaar's avatar
CalleWagenaar
Frequent Visitor
3 years ago
Solved

How to create a bar chart using start and end times.

I have another questin now. I am trying to create a graph showing how many cars are drving at a certain hour. To do this I have start times and end times in my data.  have created a time frequancy graph based on start times, which shows how many cars start at a certain time: 

 

However this only shows the start times. How do I geth this graph to show the time inbetween the stat and the end time. For example: 
If a car drove from 10:00 -13:00 using only strta times it adds one point to 10:00. I need it to add a point to 10:00, 11:00 and 12:00. How can I do this? 

  • Hi CalleWagenaar ,

     

    Based on your description, I have created a simple sample:

    Please try:

    First create a new time table:

    Then create a measure:

    Measure = SUMX('Table',IF([Start Time]<=MAX('Time'[Time])&&[End Time]>=MAX('Time'[Time]),1))

    Apply it to the visual:

    Final output:

    Best Regards,

    Jianbo Li

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

4 Replies

  • In Power Query you can use List.Generate to create the time series for each car (with hourly granularity), from Start date/hour to end date/hour.  Then you can use these calculated data points in your visual.

  • Hi CalleWagenaar ,

     

    Based on your description, I have created a simple sample:

    Please try:

    First create a new time table:

    Then create a measure:

    Measure = SUMX('Table',IF([Start Time]<=MAX('Time'[Time])&&[End Time]>=MAX('Time'[Time]),1))

    Apply it to the visual:

    Final output:

    Best Regards,

    Jianbo Li

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

    • CalleWagenaar's avatar
      CalleWagenaar
      Frequent Visitor

      This doesn't work for me, when I follow the step there are no errors. However when I try to create the graph it is blank.

      • CalleWagenaar's avatar
        CalleWagenaar
        Frequent Visitor

        I exactly followed your steps with your exact data and there is still no resut