Forum Discussion

thebigrlebowski's avatar
thebigrlebowski
Regular Visitor
3 years ago
Solved

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

TypeColorDealer LocationRadioSunroofP Locks  TypeColorCustomer LocationRadioSunroofP Locks
carredKansas110  truckblackNebraska010
truckgreenTexas100  truckredCalifornia101
caryellowUtah111  carblueMaine001
carpurpleTexas000  TruckblueFlorida000

 

- If the user selects Radio the desired output would be 

Left Result                                                                 Right Result

TypeColorDealer Location TypeColorCustomer Location
carredKansas truckredCalifornia
truckgreenTexas    
caryellowUtah    

 

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.

  • Anonymous's avatar
    Anonymous
    3 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

  • Anonymous's avatar
    Anonymous
    Not 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

     

    • thebigrlebowski's avatar
      thebigrlebowski
      Regular Visitor

      The works perfectly. Thank you!  Can you explain whats going on in the Flag measures?