Forum Discussion
Parameter Filter
Hello all, looking for assistance creating a parameter filter or slicer so a user can dispay rows with a certain category or option selected. The report consists of 2 tables next to eachother.
The example scenario details include:
- User needs to have a slicer/parameter that only has options for Radio, Sunroof, and P Locks.
- The 2 tables are being generated from 2 different queries.
- There is not a relationship between these 2 queries.
- The output of the queries are like below.
Left Query Results Right Query Results
| Type | Color | Dealer Location | Radio | Sunroof | P Locks | Type | Color | Customer Location | Radio | Sunroof | P Locks | ||
| car | red | Kansas | 1 | 1 | 0 | truck | black | Nebraska | 0 | 1 | 0 | ||
| truck | green | Texas | 1 | 0 | 0 | truck | red | California | 1 | 0 | 1 | ||
| car | yellow | Utah | 1 | 1 | 1 | car | blue | Maine | 0 | 0 | 1 | ||
| car | purple | Texas | 0 | 0 | 0 | Truck | blue | Florida | 0 | 0 | 0 |
- If the user selects Radio the desired output would be
Left Result Right Result
| Type | Color | Dealer Location | Type | Color | Customer Location | |
| car | red | Kansas | truck | red | California | |
| truck | green | Texas | ||||
| car | yellow | Utah |
I realize that I could modify the queries so that the Radio, Sunroof, and P Locks columns would be in the same column and then have an increased amount of rows, then use slicers but I would like to learn how to use parameters for something like this. This is easily done in Tableau and that is the route I took it due to time restraints but would like to understand how I could do it in Power BI.
- Anonymous3 years ago
Hi thebigrlebowski ,
Here are the steps you can follow:
1. Enter data.
2. Create measure.
Flag1 = var _select= SELECTEDVALUE('Slicer_Table'[Group]) return SWITCH( TRUE(), _select="Radio" && 1 in SELECTCOLUMNS('Left Query Results',"Radio",'Left Query Results'[Radio]),1, _select="Sunroof" && 1 in SELECTCOLUMNS('Left Query Results',"Sunroof",'Left Query Results'[Sunroof]),1, _select="P Locks" && 1 in SELECTCOLUMNS('Left Query Results',"P Locks",'Left Query Results'[P Locks]),1, 0)Flag2 = var _select= SELECTEDVALUE('Slicer_Table'[Group]) return SWITCH( TRUE(), _select="Radio" && 1 in SELECTCOLUMNS('Right Query Results',"Radio",'Right Query Results'[Radio]),1, _select="Sunroof" && 1 in SELECTCOLUMNS('Right Query Results',"Sunroof",'Right Query Results'[Sunroof]),1, _select="P Locks" && 1 in SELECTCOLUMNS('Right Query Results',"P Locks",'Right Query Results'[P Locks]),1, 0)3. Place [Flag1] and [Flag2] into Left Query Results and Left Query Results respectively.
For example, [Flag1].
Place [Flag1]in Filters, set is=1, apply filter.
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
2 Replies
- AnonymousNot applicable
Hi thebigrlebowski ,
Here are the steps you can follow:
1. Enter data.
2. Create measure.
Flag1 = var _select= SELECTEDVALUE('Slicer_Table'[Group]) return SWITCH( TRUE(), _select="Radio" && 1 in SELECTCOLUMNS('Left Query Results',"Radio",'Left Query Results'[Radio]),1, _select="Sunroof" && 1 in SELECTCOLUMNS('Left Query Results',"Sunroof",'Left Query Results'[Sunroof]),1, _select="P Locks" && 1 in SELECTCOLUMNS('Left Query Results',"P Locks",'Left Query Results'[P Locks]),1, 0)Flag2 = var _select= SELECTEDVALUE('Slicer_Table'[Group]) return SWITCH( TRUE(), _select="Radio" && 1 in SELECTCOLUMNS('Right Query Results',"Radio",'Right Query Results'[Radio]),1, _select="Sunroof" && 1 in SELECTCOLUMNS('Right Query Results',"Sunroof",'Right Query Results'[Sunroof]),1, _select="P Locks" && 1 in SELECTCOLUMNS('Right Query Results',"P Locks",'Right Query Results'[P Locks]),1, 0)3. Place [Flag1] and [Flag2] into Left Query Results and Left Query Results respectively.
For example, [Flag1].
Place [Flag1]in Filters, set is=1, apply filter.
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- thebigrlebowskiRegular Visitor
The works perfectly. Thank you! Can you explain whats going on in the Flag measures?