Forum Discussion
Another Matrix Sum Issue
- Anonymous1 year ago
Hi Adams_Apple,
Thank you for following up with the conversation. You are right that the issue lies in the time part of the logic "DATEDIFF ( TIME(0,0,0), data_Bins[Time Dumped], HOUR ) < 3". The intention here is to filter for times after midnight but before 3:00 AM on the next day of the night shift. However, this condition can be a bit fragile especially since DATEDIFF() with a static TIME(0,0,0) isn't reliable in all row contexts and can sometimes return blanks or unexpected values.
Instead we can use the TIMEVALUE() function directly to filter by the time portion. Since your night shift runs from 4:00 PM to 3:00 AM the next day, you can adjust the logic to use ">= TIME(16, 0, 0) (4:00 PM) to end of day on currentDate" and "< TIME(3, 0, 0) (3:00 AM) on currentDate + 1".
Try this:
VAR nightStart =
CALCULATE(
MIN(data_Bins[DateTime Dumped]),
data_Bins[Date Dumped] = currentDate,
TIMEVALUE(data_Bins[DateTime Dumped]) >= TIME(16, 0, 0)
)VAR nightStop =
CALCULATE(
MAX(data_Bins[DateTime Dumped]),
data_Bins[Date Dumped] = currentDate + 1,
TIMEVALUE(data_Bins[DateTime Dumped]) < TIME(3, 0, 0)
)This approach compares the actual time portion of DateTime Dumped directly, which avoids the DATEDIFF ambiguity and handles filtering more reliably.
Best Regards,.
Hammad.
Hi,
Share the download link of the PBI file. Show the problem and expected result very clearly.
thank you for replying. unfortunately to PBIX is full of proprietary information.
I am simply trying to get the sum total to add up correctly: