Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
cheid_4838
Helper IV
Helper IV

Filter function is not filtering

I have a table that contains invoice level information.  This table is connected to three lookup tables (Division, Date, driver, and tractor). Not very complex. My goal for one of my visuals is to show those transactions where no discount was applied.  

 

The result should look like the screenshot below.

cheid_4838_0-1749238252721.png

 

I created a calculation that is supposed to filter down the results by only showing those invoices with no discount, but what is happening  it's giving me a bunch of lines that don't align with the example above.  There are mutliple lines with different dates that don't match the expected result.  I have never encountered anything like this before.  Am I missing something with how the filter function should work?  

 

Fuel Spend =
CALCULATE(sum('EFS Transaction Report'[all_fuel_amount]))

 

No Rebate Fuel Spend =
VAR _Spend = CALCULATE([Fuel Spend],filter('EFS Transaction Report','EFS Transaction Report'[all_fuel_line_item_discount]=0))
RETURN
IF(ISBLANK(_Spend),0,_Spend)
 
cheid_4838_1-1749238429092.png

 

 

1 ACCEPTED SOLUTION
Ashish_Excel
Super User
Super User

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.

View solution in original post

5 REPLIES 5
danextian
Super User
Super User

Hi @cheid_4838 
Because of this:

IF(ISBLANK(_Spend),0,_Spend)

The VertiPaq engine in Power BI enhances performance by skipping unnecessary calculations when processing blank (null) values. However, if a measure is forced to return zeroes instead of blanks, the formula engine may perform a full cross-join of the dimension tables in the visual, evaluating each possible combination explicitly. This can significantly increase query execution time, as opposed to scanning only the rows where relevant combinations actually exist. It may also result in unexpected data points appearing. For example, an obsolete item, which was deactivated several years ago, might still display for a selected period, but with zero values.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
v-karpurapud
Community Support
Community Support

Hi @cheid_4838 

Could you please confirm if your query have been resolved the solution provided by  @AlexisOlson , @AlexisOlson and @Ashish_Excel ? If they have, kindly mark the helpful response and accept it as the solution. This will assist other community members in resolving similar issues more efficiently.

Thank You.

Ashish_Excel
Super User
Super User

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.

burakkaragoz
Community Champion
Community Champion

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

AlexisOlson
Super User
Super User

Does it make a difference if you filter just the column rather than the whole table?

No Rebate Fuel Spend =
VAR _Spend =
    CALCULATE (
        [Fuel Spend],
        FILTER (
            VALUES ( 'EFS Transaction Report'[all_fuel_line_item_discount] ),
            'EFS Transaction Report'[all_fuel_line_item_discount] = 0
        )
    )
RETURN
    IF ( ISBLANK ( _Spend ), 0, _Spend )

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.