Forum Discussion
Filter multiples variables in a single button
Good day, community!
I am looking for the solution to get the following type of filter buttons:
filter1: (altura > 175) && (peso > 70) && (categoria = 'vendedor')
filter2: ...
filter3: ...
filter4: ...
How can I link a button to give me range filter and subject filter together?
- Anonymous3 years ago
Hi angelosales150 ,
Please try below steps:
1. below is my test table
Table:
Table2:
2. create a measure with below dax formula
Measure = VAR cur_select = SELECTEDVALUE ( 'Table 2'[Filter] ) VAR _carros = SELECTEDVALUE ( 'Table'[carros] ) VAR _a = CALCULATETABLE ( VALUES ( 'Table'[carros] ), FILTER ( ALL ( 'Table' ), [altura] > 175 && [peso] > 70 && [categoria] = "vendedor" ) ) VAR _b = CALCULATETABLE ( VALUES ( 'Table'[carros] ), FILTER ( ALL ( 'Table' ), [altura] > 175 && [peso] > 70 && [categoria] = "entregador" ) ) VAR _c = CALCULATETABLE ( VALUES ( 'Table'[carros] ), FILTER ( ALL ( 'Table' ), [altura] > 170 && [peso] > 70 && [categoria] = "vendedor" ) ) VAR _d = CALCULATETABLE ( VALUES ( 'Table'[carros] ), FILTER ( ALL ( 'Table' ), [altura] > 175 && [peso] > 60 && [categoria] = "vendedor" ) ) VAR _val = SWITCH ( cur_select, "filter1", IF ( _carros IN _a, 1 ), "filter2", IF ( _carros IN _b, 1 ), "filter3", IF ( _carros IN _c, 1 ), "filter4", IF ( _carros IN _d, 1 ) ) RETURN IF ( ISFILTERED ( 'Table 2'[Filter] ), _val, 1 )3. add a table visual with fields, add a slicer with field, apply this measure to table visual filter pane
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- amitchandakSuper User
angelosales150 , You need to create measures with slicers and use bookmarks and button
Bookmarks
https://radacad.com/bookmarks-and-buttons-making-power-bi-charts-even-more-interactive
https://docs.microsoft.com/en-us/power-bi/desktop-bookmarksIf this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. - AnonymousNot applicable
Hi angelosales150 ,
Please try below steps:
1. below is my test table
Table:
Table2:
2. create a measure with below dax formula
Measure = VAR cur_select = SELECTEDVALUE ( 'Table 2'[Filter] ) VAR _carros = SELECTEDVALUE ( 'Table'[carros] ) VAR _a = CALCULATETABLE ( VALUES ( 'Table'[carros] ), FILTER ( ALL ( 'Table' ), [altura] > 175 && [peso] > 70 && [categoria] = "vendedor" ) ) VAR _b = CALCULATETABLE ( VALUES ( 'Table'[carros] ), FILTER ( ALL ( 'Table' ), [altura] > 175 && [peso] > 70 && [categoria] = "entregador" ) ) VAR _c = CALCULATETABLE ( VALUES ( 'Table'[carros] ), FILTER ( ALL ( 'Table' ), [altura] > 170 && [peso] > 70 && [categoria] = "vendedor" ) ) VAR _d = CALCULATETABLE ( VALUES ( 'Table'[carros] ), FILTER ( ALL ( 'Table' ), [altura] > 175 && [peso] > 60 && [categoria] = "vendedor" ) ) VAR _val = SWITCH ( cur_select, "filter1", IF ( _carros IN _a, 1 ), "filter2", IF ( _carros IN _b, 1 ), "filter3", IF ( _carros IN _c, 1 ), "filter4", IF ( _carros IN _d, 1 ) ) RETURN IF ( ISFILTERED ( 'Table 2'[Filter] ), _val, 1 )3. add a table visual with fields, add a slicer with field, apply this measure to table visual filter pane
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- angelosales150Frequent Visitor
Thanks for the answer, Anonymous !
This code is really good and this way is way better for maintenance.
- angelosales150Frequent Visitor
Hi, amitchandak.
I was looking for a solution with all the conditions in a unique line linked to a button to have a better maintenance. Just as when Q&A is used like "pessoa with peso > 40 & emprego = vendedor"