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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

How to maintain explicit filters when using ALL functions

Hi all

 

I am trying to count the values on a column, based on one of my extarnal filters but getting rid of that same external filter. See my example.

 

Country             Project ID

France                 34

France                 56

France                 34

EEUU                   21

EEUU                   34

EEUU                   67

EEUU                   43

Spain                   23

Spain                   15

 

 

This is my table, my external filter is "Project ID = 23" which belongs to Spain and this is the only filter which the report consumer will see. I want my Dax formula to show how many projects are there in Spain (looking for answer = 2) based on that only filter.

I have tried 

CALCULATE(COUNTROWS(Table);ALLEXCEPT(Table;Table[Country])) but because the Country filter is not in the report it just counts all the rows in the table.

 

Thanks a lot in advance.

1 ACCEPTED SOLUTION

hi  @Anonymous 

Just try this simple logic to get it:

Measure = 
var _country=VALUES('Table'[Country]) return

CALCULATE(COUNTA('Table'[Country]),FILTER(ALL('Table'), 'Table'[Country] in _country))

Result:

3.JPG5.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
vanessafvg
Super User
Super User

i think you might need to use selected value to filer, does this article help?

 

http://dataap.org/blog/2018/07/22/capture-the-selected-filter-in-powerbi-dax/





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

Hi @vanessafvg 

 

Looks like my Anti-Virus (ESET) is blocking me from accessing that Link, could you post here a possible answer?

 

Thanks

hi  @Anonymous 

Just try this simple logic to get it:

Measure = 
var _country=VALUES('Table'[Country]) return

CALCULATE(COUNTA('Table'[Country]),FILTER(ALL('Table'), 'Table'[Country] in _country))

Result:

3.JPG5.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you @v-lili6-msft

This worked correctly;-)

amitchandak
Super User
Super User

@Anonymous , Try like

CALCULATE(COUNTROWS(Table);filter(all(Table);Table[Country]="Spain"))

 

Not sure I got it correctly

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi amitchandak

 

That won't work, as I the consumer could choose another project form another country, like EEUU and in that case, I want my formula to count how many projects are in EEUU.

 

Thanks 

vanessafvg
Super User
Super User

when you say external filter, how are you filtering currently?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Anonymous
Not applicable

Hi Vanessa

 

I have just the "Project ID" filter in my report, in the example, the consumer is selecting the Project ID 23 in an Slicer. I want that report consumer to see the number of projects in Spain as 23 belongs to Spain. Hope I am clear enough;-)

 

Thanks a lot 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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