cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
amitdesai
Regular Visitor

Filtering table based on measure

Hi,

 

I have a table with two columns, index and values (ranging from 1 to 100).  I want to filter the table based on user inputs, 'input value' and 'tolerance' (in percentage).  For example, if user inputs '50' as 'input value', and '10' as tolerance, then I want to filter the table with value ranging between 45 and 55.  I created 'What-if' parameters for both input value and tolerance, and created measures 'Min Value' and 'Max Value' to define the limits for filtering.  How do I use these measures to filter the data ('Display Table').  I can use a slicer to filter the table ('Value Filter'), but I want to also filter the data based on input value and tolerance.

powerBIdekstop_screenshot.jpg

 

Thank you,

Amit.

1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @amitdesai ,

 

Try to do like this.

1. create a measure.

Filter = 
IF(
    MAX(Sheet8[Index]) >= [Min] && MAX(Sheet8[Index]) <= [Max],
    1,0
)

2. Add the measure to the "Filters on this visual".

v-lionel-msft_0-1611558007761.png

 

Best regards,
Lionel Chen

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

4 REPLIES 4
v-lionel-msft
Community Support
Community Support

Hi @amitdesai ,

 

Try to do like this.

1. create a measure.

Filter = 
IF(
    MAX(Sheet8[Index]) >= [Min] && MAX(Sheet8[Index]) <= [Max],
    1,0
)

2. Add the measure to the "Filters on this visual".

v-lionel-msft_0-1611558007761.png

 

Best regards,
Lionel Chen

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

Hi Lionel Chen,

 

This solution works!  I used the new filter and display table with rows having '1' as filtered value.  My next step is to figure out how to not display the filter column or make it invisible.

amitchandak
Super User IV
Super User IV

@amitdesai , You can create a new measure like below. Main thing is values /force a context to filter

 

new measure =
var _min = minx(allselected(slicer), slicer[value])
var _max = maxx(allselected(slicer), slicer[value])
return
calculate(sumx(filter(values(Table[Index]) , [measure] >=_min && [measure] <=_max),[measure]))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Thank you for the quick response!  I do not understand what the code is trying to achieve.  Here is the modified code based on your input:

 

new measure =
var _min = minx(allselected('TEST DATA'[Value]), [MinValue])
var _max = maxx(allselected('TEST DATA'[Value]), [MaxValue])
return
calculate(sumx(filter(values('TEST DATA'[Index]) , [measure] >=_min && [measure] <=_max),[measure]))
 
TEST DATA[Value] is the column with values that need to be filtered and TEST DATA[Index] is the other column. [MinValue] and [MaxValue] are measure that determine the lower and upper limit of filtering, respectively (based on the 'Input Value' and 'Tolerance').  Also, I get an error for the new measure indicating circular dependency.
 
Your help is extremely appreciated!

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Urdu Hindi D365 Bootcamp 768x460.png

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors