Forum Discussion
Dynamically Find Peak Hour Time
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.
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?
- lbendlin6 years agoSuper 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.
- Greg_Deckler6 years agoCommunity Champion
Drewz - You can set a column to Time in Power Query and it will come through to the data model in a Time format. Use Column tools and set to a Time data type and format to your desired time format.
What I do not understand is your peak and how you want that to be chosen. You cannot use a measure in a slicer but you should be able to find your peak easy enough but I need to understand more about how your data is coming in. Is it coming in in 15 minute intervals or ?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.- Drewz6 years agoHelper II
Hi Greg_Deckler,
Thanks for your reply. I do set the column to Time in Power Query, but CALENDARAUTO still detects the 1899 date. But it seems CALENDARAUTO is not recommended, so I'll avoid using it form now on.
In my original post I added a link to my pbix file so you could see exactly what my data looks like. Did my link work? Yes it is in 15 minute intervals. So I'm guessing I'd need to do a rolling sum of 4 x 15 min counts. But even if I do that, how can I extract what hour that occurs to create a peak hour filter for the morning and evening.
- Greg_Deckler6 years agoCommunity Champion
Drewz - See page 2. I'm still not sure exactly what you want but I did a chart that had the time in the correct format and date as well as created an Hour column and showed it that way. If you really want to chart to essentially only show peak traffic, you would need to implement what I call a Complex Selector. You can see several examples here.
https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Complex-Selector/m-p/1116633#M534
Your PBIX is attached with updates. (below sig)