Forum Discussion
Power Bi aggregating data till hour level
- 4 years ago
Hi, khush19 ;
You don't need to break my fact data for each row, you could create a hourslicer table as slicer. then create a flag measure .
1.create a table.
hourslicer = GENERATESERIES(1,24,1)2.create a flag measure.
flag = IF(ISFILTERED(hourslicer[Value]), IF ( HOUR ( MAX ( [StartTime] ) ) = SELECTEDVALUE ( 'hourslicer'[Value] ) && MINUTE ( MAX ( [StartTime] ) ) = 0, 1, IF ( HOUR ( MAX ( [StartTime] ) ) < SELECTEDVALUE ( 'hourslicer'[Value] ) && HOUR ( MAX ( [EndTime] ) ) >= SELECTEDVALUE ( 'hourslicer'[Value] ), 1, 0)),1 )3.then apply it into visual filter.
The final output is shown below:
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. - 4 years ago
khush19 Are you wanting a between filter? If so then you don't need any relationship between the Date, Hour and Fact tables. You can do all the filtering with DAX.
Similar to my post about it here: https://excelwithallison.blogspot.com/2020/06/dax-approximate-lookup.html
You'll need to combine the Date/Time selections from both slicers and compare to the Start Date/Time and End Date/Time columns in your Fact table.
If you're still struggling after the blog, let me know and I may have time to provide more specific example.
Hi Allison,
Thanks for the reply,I will change the table purely to have one dimdate and other table with 24 rows which means 24 hours.but still my question is do i need to break my fact data for each row?like StartTime 2021-09-08 06:00:00.000 and endTime 2021-09-08 12:30:00.000 so do i need to break one row into 06,07,08,09,10,11,12 rows and then push to powerbi?
khush19 In your fact table you just need the Start Date and Start Hour. You can do this in Power Query easily. Click Transform Data in Power BI, then in the Add Column tab click Date > Date only (with the start date column selected).
Select the Start Date column again. Click Add Column > Time > Hour.
You can then use those two new columns to relate to your date and Hour dim tables. Does that make sense?