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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
setis
Post Partisan
Post Partisan

FILTER with "NOT" issue

Dear experts,

 

I am doing someting wrong when using NOT in a filter.

 

I have a calculated column that is giving me either "Above Average" or "Below Average" in my Sales table

 

I am trying to filter the "Above Average" Sales amount using the following measure:

 

#Sales AboveAvrg = 
VAR SalesAmount = SUMX ( Sales; Sales[Quantity] * Sales[Net Price] )
RETURN
CALCULATE(SalesAmount;
FILTER(ALL(Sales);NOT(
    Sales[Delivery State] = "Below Average")))

The problem is that this is giving me the full Sales Amount.

 

I am able to obtain the correct result using:

#Sales AboveAvrg2 = 
CALCULATE([Sales Amount];
FILTER(Sales;Sales[Delivery State] = "Above Average"))

NotISSUE.PNG

Why is the first one not working?

 

 

Please find the file here: https://drive.google.com/file/d/1MlHXk1r6icFmlPrwV7wulN5k49C95xkt/view?usp=sharing

 

 

 

1 ACCEPTED SOLUTION

@setis 

 

Sorry for late reply.

 

This is because you are using ALL(Sales) in the first formula

 

All removes all the filters from the Table used as argument and associated one side Tables .

 

 


Regards
Zubair

Please try my custom visuals

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

@setis 

In the first MEASURE you are using a Variable as expression for CALCULATE function.
Variables are just store of value. They do no respond to EVALUATION CONTEXTs

 

#Sales AboveAvrg = 
VAR SalesAmount = SUMX ( Sales; Sales[Quantity] * Sales[Net Price] )
RETURN
CALCULATE(SalesAmount[Sales Amount];
FILTER(ALL(Sales);NOT(
    Sales[Delivery State] = "Below Average")))

 

 

 


Regards
Zubair

Please try my custom visuals

Dear @Zubair_Muhammad ,

Thanks a lot for your answer, 

I tried to obtain the correct result using the measure for Sales Amount instead. I get the correct result, but not respecting the row context. 

Please see the image below. 

How can I obtain the result I get in the third column using the NOT function?

 

NotISSUE2.PNG

@setis 

 

Sorry for late reply.

 

This is because you are using ALL(Sales) in the first formula

 

All removes all the filters from the Table used as argument and associated one side Tables .

 

 


Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.