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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Erin001
Helper II
Helper II

How does function FILTERS() work?

Hi,

 

How can I see if a value is in the return of function FILTERS()? e.g., I have a filter Brand(A, B, C), and I want to know if Brand A is selected to filter the data.

 

Or there are some other functions I can use to do it if Filters() is not a good choice,

 

Thanks!

1 ACCEPTED SOLUTION

Hi @Erin001,

 

Try measure instead of using calculated column.

 

3.PNG4.PNG

 

FILTERS() in measure will return dynamic result, however it will always return the entire column values in a calculated column.

 

Thanks,
Xi Jin.

 

View solution in original post

3 REPLIES 3
v-xjiin-msft
Solution Sage
Solution Sage

Hi @Erin001,

 

Yes. Brand A is selected to filter the data.

 

FILTERS() function returns the values that are directly applied as filters to columnName. Please refer to following simple sample:

 

As you can see the Source Table contains 9 rows as A to I. And the Filters table only contains 3 rows A to C. Then create a measure for Source Table with expression like:

 

Count Rows = COUNTROWS(FILTERS('Filters'[User]))

The result will show as 3 since the Source Table has been filtered by Filters table.

 

3.PNG

 

Thanks,
Xi Jin.

Hi @v-xjiin-msft

 

Thanks...and here's what I'd tried and got confused:

 

when I select the brand(s)(A,B, or C) from the Filter Brand, I always can see row# = CounterRows(Filters(Product[Brand]) changes with what I selected, e.g, if I select A, row# = 1; if I select A and B, Row# = 2; if I select A, B and C, row# =3.

 

at the same time, I created column Flag = if(ContainsRow(Filters(Product[Brand],"A"), "T","F") to test if A is selected as filter value (I tried B and C also). No matter A is seleted or not, always the Flag  = "T", which means Filters(Product[Brand]) always contains all A, B and C as its values, but CounterRows() tells me another story that Filters() only contains what I select.

 

what I want to achieve is checking if "A" is selected and applied as filter on the dashboard. I would like to know if containsRow() or IN functions can work with FILTERS() to get things done. Or any other ADX function can do it.

 

Thanks!

 

Hi @Erin001,

 

Try measure instead of using calculated column.

 

3.PNG4.PNG

 

FILTERS() in measure will return dynamic result, however it will always return the entire column values in a calculated column.

 

Thanks,
Xi Jin.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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