Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I have data in 5-minute intervals, and I need a measure for the number of hours above a threshold.
Hours Above Threshold =
CALCULATE( COUNTROWS ( DataRecords ) / 12,
FILTER ( DataRecords, DataRecords[NumericValue] > 1000 )
)
Here is sample data for 4 hours. I expect the measure to return (31 periods above 1,000) / 12 = 2.58 hours, but instead I'm getting blank.
Date | HourEnding | Interval | NumericValue |
Wednesday, May 8, 2024 | 21 | 12 | 295.75 |
Wednesday, May 8, 2024 | 21 | 11 | 389.97 |
Wednesday, May 8, 2024 | 21 | 10 | 644.84 |
Wednesday, May 8, 2024 | 21 | 9 | 639.66 |
Wednesday, May 8, 2024 | 21 | 8 | 1237.32 |
Wednesday, May 8, 2024 | 21 | 7 | 1341.34 |
Wednesday, May 8, 2024 | 21 | 6 | 2667.03 |
Wednesday, May 8, 2024 | 21 | 5 | 4486.05 |
Wednesday, May 8, 2024 | 21 | 4 | 4993.16 |
Wednesday, May 8, 2024 | 21 | 3 | 5018.64 |
Wednesday, May 8, 2024 | 21 | 2 | 5018.54 |
Wednesday, May 8, 2024 | 21 | 1 | 4979.51 |
Wednesday, May 8, 2024 | 20 | 12 | 4984.58 |
Wednesday, May 8, 2024 | 20 | 11 | 4592.68 |
Wednesday, May 8, 2024 | 20 | 10 | 4301.46 |
Wednesday, May 8, 2024 | 20 | 9 | 3263.87 |
Wednesday, May 8, 2024 | 20 | 8 | 2993.27 |
Wednesday, May 8, 2024 | 20 | 7 | 3323.29 |
Wednesday, May 8, 2024 | 20 | 6 | 2320.04 |
Wednesday, May 8, 2024 | 20 | 5 | 2042.14 |
Wednesday, May 8, 2024 | 20 | 4 | 2013.85 |
Wednesday, May 8, 2024 | 20 | 3 | 859.21 |
Wednesday, May 8, 2024 | 20 | 2 | 1043.87 |
Wednesday, May 8, 2024 | 20 | 1 | 1928.56 |
Wednesday, May 8, 2024 | 19 | 12 | 258.03 |
Wednesday, May 8, 2024 | 19 | 11 | 1145.95 |
Wednesday, May 8, 2024 | 19 | 10 | 1531.26 |
Wednesday, May 8, 2024 | 19 | 9 | 3109.66 |
Wednesday, May 8, 2024 | 19 | 8 | 2985.92 |
Wednesday, May 8, 2024 | 19 | 7 | 1160.27 |
Wednesday, May 8, 2024 | 19 | 6 | 653.86 |
Wednesday, May 8, 2024 | 19 | 5 | 450.01 |
Wednesday, May 8, 2024 | 19 | 4 | 564.36 |
Wednesday, May 8, 2024 | 19 | 3 | 489.21 |
Wednesday, May 8, 2024 | 19 | 2 | 266.46 |
Wednesday, May 8, 2024 | 19 | 1 | 286.67 |
Wednesday, May 8, 2024 | 18 | 12 | 323.72 |
Wednesday, May 8, 2024 | 18 | 11 | 307.94 |
Wednesday, May 8, 2024 | 18 | 10 | 459.21 |
Wednesday, May 8, 2024 | 18 | 9 | 430.08 |
Wednesday, May 8, 2024 | 18 | 8 | 675.21 |
Wednesday, May 8, 2024 | 18 | 7 | 1046.2 |
Wednesday, May 8, 2024 | 18 | 6 | 1415.14 |
Wednesday, May 8, 2024 | 18 | 5 | 1964.49 |
Wednesday, May 8, 2024 | 18 | 4 | 1338.16 |
Wednesday, May 8, 2024 | 18 | 3 | 1631.06 |
Wednesday, May 8, 2024 | 18 | 2 | 1975.69 |
Wednesday, May 8, 2024 | 18 | 1 | 1942.8 |
Thanks for your help and advice!
Solved! Go to Solution.
Hi, @ervarble
I used part of the sample data you provided below:
I corrected your DAX expression as follows:
Hours Above Threshold =
VAR ThresholdCount =
CALCULATE(
COUNTROWS(DataRecords),
FILTER(DataRecords, DataRecords[NumericValue] > 1000)
)
RETURN
DIVIDE(
ThresholdCount * 5, // 5 minutes per time slot
60 // Convert to hours
)
The results are as follows:
In your Power BI, you are trying to count the number of time slots above a certain threshold (1000) and convert those time slots to hours. However, there are a couple of issues with your DAX expression that need to be fixed.
First, the COUNTROWS function returns the number of rows, not the number of time periods (if each row represents a 5-minute time period). In order to calculate the number of time periods above the threshold, you should use the COUNTROWS function directly, without dividing by 12 (since you haven't converted it to hours).
Then, in order to convert these time periods to hours, you need to know the length of time that each time period represents (5 minutes in your example), and you need to multiply the number of time periods by this length and then divide by 60 (since there are 60 minutes in an hour)
Best Regards,
hackcrr
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @ervarble
I used part of the sample data you provided below:
I corrected your DAX expression as follows:
Hours Above Threshold =
VAR ThresholdCount =
CALCULATE(
COUNTROWS(DataRecords),
FILTER(DataRecords, DataRecords[NumericValue] > 1000)
)
RETURN
DIVIDE(
ThresholdCount * 5, // 5 minutes per time slot
60 // Convert to hours
)
The results are as follows:
In your Power BI, you are trying to count the number of time slots above a certain threshold (1000) and convert those time slots to hours. However, there are a couple of issues with your DAX expression that need to be fixed.
First, the COUNTROWS function returns the number of rows, not the number of time periods (if each row represents a 5-minute time period). In order to calculate the number of time periods above the threshold, you should use the COUNTROWS function directly, without dividing by 12 (since you haven't converted it to hours).
Then, in order to convert these time periods to hours, you need to know the length of time that each time period represents (5 minutes in your example), and you need to multiply the number of time periods by this length and then divide by 60 (since there are 60 minutes in an hour)
Best Regards,
hackcrr
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Strange, I copy your table and measure and i got the result you are expecting. Make sure you don't have other filter in the side pane that might be causing you to get blanks.
User | Count |
---|---|
95 | |
86 | |
78 | |
72 | |
67 |
User | Count |
---|---|
110 | |
104 | |
84 | |
65 | |
63 |