Forum Discussion
Filter function is not filtering
- 1 year ago
Hi,
Does this measure work?
_Spend = CALCULATE([Fuel Spend],'EFS Transaction Report'[all_fuel_line_item_discount]=0)If not, then share the download link of the PBi file and show the problem there very clearly.
Hi cheid_4838 ,
This kind of issue usually happens because of how context and relationships work in DAX, especially when you use FILTER over an entire table instead of just the column you need. When you filter the whole table, the filtering context might not apply as you expect, and you can end up with unexpected results.
Try this approach:
Instead of filtering the entire table, create a filter directly on the column where the discount is applied. That way, the filter is more precise and the calculation will only consider rows where the discount is zero.
Here’s how you can rewrite your measure:
No Rebate Fuel Spend :=
VAR _Spend =
CALCULATE(
[Fuel Spend],
'EFS Transaction Report'[all_fuel_line_item_discount] = 0
)
RETURN
IF(ISBLANK(_Spend), 0, _Spend)- This measure checks directly for rows where [all_fuel_line_item_discount] = 0 and sums the relevant fuel spend.
- Using this filter at the column level is usually more reliable than wrapping the whole table in the FILTER function, which can sometimes confuse row and filter context.
Extra tips:
- Double-check that [all_fuel_line_item_discount] is always numeric (no blanks, errors, or text values).
- Make sure your relationships between lookup tables and the fact table are active and set correctly, as inactive or ambiguous relationships can also cause odd filter behavior.
- If you’re still seeing unexpected results, try creating a simple table visual with just [invoice] and [all_fuel_line_item_discount] to confirm that your data matches what you expect.
Let me know if this helps or if you’re still running into issues—happy to troubleshoot further if needed!
translation and formatting supported by AI