Forum Discussion
Power BI Slicer - Dynamic Filtering Based on Selected Car Model Price Range with "Higher" and "Lower
Hello Community.
I have a table where:
Column A contains the names of car models.
Column B contains the price of each model.
I've created a slicer that only includes the models from my specific car brand, allowing me to filter by brand models.
Additionally, I created two new parameter tables using the "New Parameter" feature:
Higher Table: This contains values like 10,000 / 20,000 / 30,000.
Lower Table: This contains values like -30,000 / -20,000 / -10,000.
Next, I built a matrix visual that displays all the models from my table.
Objective:
I want to achieve the following behavior:
When I select a model from my brand in the slicer, and I also set values in the "Higher" and "Lower" slicers, I want the table to filter and show only the models that fall within the price range based on the selected model's price.
For example:
If I select a model that costs 115,800 and I select 20,000 from the "Higher" slicer and -10,000 from the "Lower" slicer, the visual should display only the models priced between 105,800 and 135,800.
Challenges I'm Facing:
Despite several attempts, I'm struggling to get the table to filter correctly based on the price range calculated from the selected model's price and the "Higher" and "Lower" slicers.
Here's a summary of the steps I've tried:
Created a slicer that only filters models from my brand.
Added two separate parameter tables (Higher and Lower) to set a dynamic price range.Tried using SWITCH and CALCULATE functions, but the visual doesn't seem to respond correctly to these filters.
What I need: A working solution where, based on the model I select and the values from the "Higher" and "Lower" slicers, the matrix visual dynamically updates to display models within the specified price range.
Example of the Desired Result:
If the selected car costs 115,800, and the "Higher" slicer is set to 20,000 while the "Lower" slicer is set to -10,000, I need the matrix to show all models that fall between 105,800 and 135,800.
Can someone please help me set up the correct DAX expressions or provide guidance on how to correctly apply this filter logic in Power BI?
3 Replies
- lbendlinSuper User
The critical part here is that you need to use disconnected tables for your over/under slicers, and a measure as a visual filter on your main table data. Is that how you set it up?
- lucas_conradoNew Member
Yes!
This is the measure that i am trying to use. The idea is to return '1' for the vehicles that are in the range and '0' for the vehicles that are not.
If i use the measure for lower and higher in a card, the return is correct. But if i use it on the table that i want to filter, it is considering price of the vehicles in each line (it is not considering by the model that i selected in the slicer:
measure:
IsInRange =
VAR Higher = SELECTEDVALUE('Higher'[HigherValue])
VAR Lower = SELECTEDVALUE('Lower'[LowerValue])
VAR SelectedPrice = [SelectedCarPrice]
VAR MinPrice = SelectedPrice + Lower
VAR MaxPrice = SelectedPrice + Higher
RETURN IF(
'Carros'[Preço] >= MinPrice && 'Carros'[Preço] <= MaxPrice,
1,
0
)- lbendlinSuper User
Looks good. If it doesn't work as a filter for the table visual then you would need to check your data model for any side effects.
If you like you can post a sample file with your current project status.