The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi Everyone,
So this is my code:
Solved! Go to Solution.
Hi @kylee_anne
You need to wrap the second part of the CALCULATE statement in a FILTER function to accurately apply row by row filtering. I've also added INT to ensure the date you are using is only using the date if the type is actually datetime. Finally, i've added +0 to deal with any blanks.
Delivered Last 24hrs =
VAR toddy = MAX('Report Date'[Report Date])
VAR yesterday = toddy - 1
RETURN
CALCULATE(
SUM('Daily Cement Delivered'[Value]) + 0,
FILTER(
'Daily Cement Usage',
INT('Daily Cement Usage'[Date]) = INT(yesterday)
)
)
I hope this helps, please give a thumbs up and mark as solved if it does, thanks!
Hi @kylee_anne
The issue is happening because your reconstructed date is being compared to a datetime column, and the time portion in the datetime is preventing a proper match. To fix this, you need to compare only the date part without the time. You can do this by using INT or DATEVALUE to strip out the time from both sides of the comparison. Also, wrap your filter logic inside a FILTER function so it applies row-by-row to the table. Using ALL inside the FILTER ensures that no existing filters block your comparison. This way, the calculation will correctly match the intended date and return only the relevant rows instead of summing everything.
Hi @kylee_anne
You need to wrap the second part of the CALCULATE statement in a FILTER function to accurately apply row by row filtering. I've also added INT to ensure the date you are using is only using the date if the type is actually datetime. Finally, i've added +0 to deal with any blanks.
Delivered Last 24hrs =
VAR toddy = MAX('Report Date'[Report Date])
VAR yesterday = toddy - 1
RETURN
CALCULATE(
SUM('Daily Cement Delivered'[Value]) + 0,
FILTER(
'Daily Cement Usage',
INT('Daily Cement Usage'[Date]) = INT(yesterday)
)
)
I hope this helps, please give a thumbs up and mark as solved if it does, thanks!
User | Count |
---|---|
24 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
29 | |
11 | |
11 | |
9 | |
9 |