Forum Discussion
Calculate last hour data
Hi all,
I'm pretty new in Power BI, I'm seeking a solution calculate last specific hour.
As I searched on Google, Power BI has a DATEADD function can help this but this function just only support for calculate previous dates.
My data has Time field per hour and count data for each hour.
| Time | Count |
| 01/01/2018 10:00:00 PM | 4 |
| 01/01/2018 11:00:00 PM | 2 |
| 02/01/2018 12:00:00 AM | 2 |
| 02/01/2018 01:00:00 AM | 6 |
| 02/01/2018 02:00:00 AM | 4 |
| 02/01/2018 03:00:00 AM | 9 |
| 02/01/2018 04:00:00 AM | 0 |
Is there any DAX function support calculate last hour?
- Anonymous6 years ago
Hi all,
I found the solution and want to share with you.
Please following this link.:
https://exceleratorbi.com.au/solving-a-complex-time-problem-in-power-bi/
7 Replies
- az38
Community Champion
Anonymous
what is your desired result for this data sample?
- AnonymousNot applicable
Hi az38 ,
My desired result if last 2 hours is:
Time Count count last 2 hours 01/01/2018 10:00:00 PM 4 01/01/2018 11:00:00 PM 2 02/01/2018 12:00:00 AM 2 4 02/01/2018 01:00:00 AM 6 2 02/01/2018 02:00:00 AM 4 2 02/01/2018 03:00:00 AM 9 6 02/01/2018 04:00:00 AM 0 4 - az38
Community Champion
Anonymous
it depends on how you calculate count but try
Measure = CALCULATE(SUM([Count]), FILTER(ALL('Table'), DATEDIFF('Table'[Time], SELECTEDVALUE('Table'[Time]), HOUR)=2))
- v-alq-msft
Community Support
Hi, Anonymous
If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.
Best Regards
Allan
- AnonymousNot applicable
Hi all,
I found the solution and want to share with you.
Please following this link.:
https://exceleratorbi.com.au/solving-a-complex-time-problem-in-power-bi/