Forum Discussion

Drewz's avatar
Drewz
Helper II
6 years ago

Dynamically Find Peak Hour Time

Hi All,

I've been searching the internet and the Power BI community for ages and I can't find anything that matches what I'm trying to do, so I'm stumped. 

 

I have intersection vehicle count data (in 15 minute intervals) at two sites in the attached sample, but this will eventually expand to 100s of sites (Link to PowerBI file).  There is morning and afternoon peak count data. I want to be able to select a site and dyncamically calculate when the peak hour occurs for both the morning and evening periods. I then want to be able to create a slicer or button to filter by either the morning or evening peak and then update my column chart.  The peak hour is different for each intersection, so it can't be a set hour. 

 

And when my column chart is showing the whole count period, how can I highlight the morning and evening peak hours as I've drawn below. I've seen it done, I just can't figure out how to do it :(.

 

One last question. When I import time from Excel, it has the data 31/12/1899 attached to it. Just wondering if I'm doing something wrong as it prevents me from using the AUTOCALENDAR() option as it starts from 1899 even when I change the format to Time only. Although as a work around I can use AUTOCALENDAR with a start year, but just wondering if I'm doing something wrong when I import and format that initial data. 

Thanks in advance, 

Cheers Drew

11 Replies

  • Never use CALENDARAUTO - always (ALWAYS) use your own Dates table. And always disable auto date/time hierarchies.  

     

    DateTime values without Date will start at the date boundary (12/31/1899) - it is what it is.  Use just the fractional part of the value if you want to avoid that.

     

    Within your data, can you even say what is morning and what is afternoon?  Will you have scenarios with more than two peak times per day? 

     

    What you describe seems to call for proper statistical tools. Maybe an R or Python script and visual can produce the required results. DAX itself is most likely not sufficient.

     

     

    • Drewz's avatar
      Drewz
      Helper II

      lbendlin ,

      thanks for the tips re CALENDARAUTO and disabling date/time hierachies. I've heard this mentioned before, but haven't worked out why. But I can Google that. 

       

      I could potentially have a midday peak as well if that data is collected, but for now my focus is just on morning and evening peaks. Baby steps. 

       

      I wasn't sure what you mean by your question re what is morning and what is afternoon (evening). Basically the morning is within the AM time period and evening would be in the PM period. But I'm sure you figured that out, so I'm not sure what you were asking me.

       

      I'm hoping there is a way of doing this with DAX. I just can't figure out where to start. I found some info on calculating a rolling average. I assume I could apply that to a rolling sum. Could that work? 

       

       

      • lbendlin's avatar
        lbendlin
        Super User

        Is morning until 11am, or is it until 11:59am ? etc.

         

        As you may have noticed by now, in BI oftentimes a chart solution is MUCH easier to achieve and to comprehend than a numbers based solution for exactly the same question.

         

        A rolling window sum only gets you so far. Eventually the question will be a question of slope. IE - is the current value bigger or smaller than the previous one?  For example you could highlight the first bar that is bigger than its successor. That will work for perfect bell curves but will not work for your real world data with its camel humps.

         

        I would go with a rolling average, and then apply the above test to that.