Forum Discussion
Make measure ignore specific filter
This should be simple but I just can’t solve it :)
I have a report page with several filters and a measure Amounts = SUM(Table.Amount). Now I’d like Amounts to ignore just one of the filters, a Page filter on Table.ShippingDate. By ignore I mean that Amounts should calculate as if that filter doesn’t exist. How to do this using DAX? I’ve tried everything I can think of using CALCULATE ALL, ALLEXCEPT, FILTER etc. but nothing seem to work.
Can anybody help me?
--- EDIT ---
I've narrowed this problem down something I've illustrated clearly in this Power BI report. Please check it out and see if you can understand why Bookmark 1-problem occurs:
https://drive.google.com/file/d/1PqKp5wjAEwHuL2UU-gUjFb39WrVas4qn/view?usp=sharing
This is not really an issue. It is clearly explained in this article from Alberto. It is happening because of Auto Exist feature in DAX.
Besides, creating a seperate dimension table is not really a workaround, but rather a best practice. A Star Schema is always considered best when working with Power BI Datamodel. This is what makes it more powerful!
34 Replies
- AnonymousNot applicable
Hey guys!
It's dead simple, really. Use the ALL function to remove a filter on a specific column like this:Measure = calculate(Expression,ALL(column-you-want-to-remove-filter))
That's it. ALL, used inside a CALCULATE expression, works like REMOVEFILTER.
- akshaybanayeRegular Visitor
What if the filter is also using a measure (visual level filter)?
- shasFrequent Visitor
this does not work anymore
- wagrezy
Helper I
Yes, confirmed. It works with Calculate([expression],ALL([column name])).
- AnonymousNot applicable
I see a lot of responses that it works with ALL, but no one adresses the specifik problem/bug in my example (download file below to see my example). There I illustrate that in some cases it won't work.
- AnonymousNot applicable
Hey, I had a similar situation that I found a solution to. I needed the sum of Table1.Amount, but ignoring any filters on Table1.Filter. I tried "Calculate( Sum( Table1.Amount) , All(Table1.Filter))" but this did not work. It didn't work because even though Table1.Filter was not being directly filtered, it was being crossfiltered by Table2.Filter. To ignore the crossfilter, I tried this and it worked:
Calculate( Sum( Table1.Amount) , All(Table1.Filter), All(Table2.Filter) )
- EPNew Member
Thank you Anonymous!! Solved my problem perfectly!
- Greg_Deckler
Community Champion
I believe what you want is the Column variant of the ALL function.
https://msdn.microsoft.com/en-us/library/ee634795.aspx
ALL (Column[, Column[, …]]) Removes all filters from the specified columns in the table; all other filters on other columns in the table still apply. All column arguments must come from the same table.
The ALL(Column) variant is useful when you want to remove the context filters for one or more specific columns and to keep all other context filters.Therefore,:
Measure = CALCULATE([Amounts],ALL(Table[ShippingDate]))
That *should* ignore any filters on Table[ShippingDate] and preserve all other filters.
- AnonymousNot applicable
Hi again
I thought so too, but in this specific case it doesn't seem to work. I narrowed it down to understand that it has to do with another filter being involved somehow!? I've created a file that illustrates this very easily with bookmarks. (Righ click and "Save link as...")
- v-huizhn-msft
Microsoft Employee
Hi Anonymous,
Please click Format on Home page->Edit interactions->select the None(highlighted in bule line), let the ShippingDate filter does not affect the visual. It will return correct result as follows.
Best Regards,
Angelia
- Nelson-WongFrequent Visitor
I found this works perfectly.
CALCULATE(expression, ALL())
- shasFrequent Visitor
doesnot work
- AnonymousNot applicable
Hi,
Not sure if this is what you are looking for, but if you select a slicer and then go to the format menu and click "edit interactions" you can turn off a visual you don't want to be filtered by that slicer
Thanks,
- AnonymousNot applicable
Yup, I figured it out.
I also created a measure to do the same for another dashboard.
Thanks for responding though. Power BI community is great !!
- AnonymousNot applicable
Would you please let me know how did you resolve this I am facing similar issue. TIA
- Tom_Y
Advocate II
For anyone who has been struggling for days/ hours, this is my solution to my problem, the "All" is working, but you need to plan if you want to put it first, or you want to it after your filter in calculation.Mine is that I need to calculate based on specific year filter (e.g. 4 years average in 2020-2024), but then I can't let it influenced by filter in Matrix.
Household_FY_20/24 =DIVIDE(CALCULATE(DISTINCTCOUNT('Project_Table'[ClientID]),'Date_Table'[FY] IN {"FY20/21", "FY21/22", "FY22/23", "FY23/24"},ALL('Date_Table'[FY])),4) - PaulDBrown
Community Champion
How about something along the lines of:
ignore filter ‘column x’= IF(ISFILTERED(‘table[column x]), [measure 1], [measure 2])
if you don’t want to compute [measure 1], you can substitute it for BLANK() for example.
- AnonymousNot applicableThanks, but I don’t see how ISFILTERED could solve this problem!? Can you illustrate how you’d successfully apply it in the example file I posted above?
- empiresFrequent Visitor
Hey buddy, did you solve this problem? I'm facing the same issue on PowerBI, I have two different data segmentation filter (on date columns 'A' and 'B') and I need to completely ignore one of filters on measure, using DAX, because my measure is used on other formulas.
How could we solve this problem?
I think ISFILTERED function doesn't work because regardless of the column 'A' is filtered or not, I need to ignore filter only on that column 'A'.
- manito969Frequent Visitor
could you solve it
- tananichFrequent Visitor
Hi, has anyone solved this?
I'm having smth similar in PowerBI, I need to completely ignore one of columns in my measure, using DAX.
- AnonymousNot applicable
The same thing.
It's very simple work by fixed lod in Tableau but in PBI...
BR,
Anastasiia Lagunova
- Greg_Deckler
Community Champion
Anonymous, Anonymous, tananich, manito969, empires - OK, I believe that this is an issue that marcorusso and I took a look at in another thread and Marco wrote up a nice blog article about. I have the fix in the attached PBIX. Basically, take ShippingDate and create another table using DISTINCT('Table'[ShippingDate]) Then relate the tables. Use this other table as your slicer and change your measure to refer to this new table. As Marco explains, this is not technically a bug but a pre-filtering "feature" of DAX.
- charleshale
Continued Contributor
Can you try calculate ( [measure], allexcept ( .......the one item you're trying to have work as a filter....)?
And if you need to, you could go to the table that your filtering against and add custom columns to allow easier filters
- AnonymousNot applicable
I have the same problem - trying to calculate the Fiscal Budget for a year and need to ignore the month filter ( YYYY,MM are the filters). Why can't Microsoft make is easy like Tableau for standard time functions ?
- AnonymousNot applicable
Thanks, Greg the solution you proposed works. Really counterintuitive if I have to define the measure on the Date dimension table.
For now it works and that's all I care about