Forum Discussion
Filter multiples variables in a single button
- 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.
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.
- angelosales1503 years agoFrequent Visitor
Thanks for the answer, Anonymous !
This code is really good and this way is way better for maintenance.