Forum Discussion

Thom_'s avatar
Thom_
Frequent Visitor
4 years ago
Solved

Field Parameters - Individual Filters

Hi all!!

 

I have been using the field parameters feature (successfully I think) and now have a different issue that I'm wondering if it can be done. I will explain a simplified version of what I have:

 

Consider a table of 5 customers A-E (Col 1). There are then 3 extra columns (Flag1, Flag2, and Flag3) that are flags giving a 'Y' or a 'N'.

CustomerFlag1Flag2Flag3
AYYN
BYNN
YNN
DNNY
ENYY

 

My fields parameter slicer works in that if I select Flag1 only, the Flag1 column and the Customer column are shown:

CustomerFlag1
AY
BY
Y
DN
EN

 

How can I make it so that depending on the column selected only rows where 'Y' is present are shown. I have tried putting an individual filter on Flag1 to show only when value contains 'Y' which works:

 

CustomerFlag1
AY
BY
Y

 

HOWEVER, if I select Flag2 the same rows are displayed, in which case I see:

 

CustomerFlag2
AY
BN
N

 

where I would want to see:

 

CustomerFlag2
AY
EY

 

I know this is a new feature but does anyone have a solution? Many thanks in advance!!!

  • Hi, Thom_ ;

    Sorry for the late recovery.

    You could change it.

    filter2 = SWITCH(MAX(Parameter2[Parameter2]),"Fl1", IF( [Fl1]="Y",1),"Fl2", IF( [Fl2]="Y",1),"Fl3", IF([Fl3]="Y",1))

    The final show:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

6 Replies

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, Thom_ ;

    Try to create a filter measure.

    filter = SWITCH(MAX('Parameter'[Parameter]),
    "Flag1", IF( MAX('Table'[Flag1])="Y",1),
    "Flag2", IF( MAX('Table'[Flag2])="Y",1),
    "Flag3", IF( MAX('Table'[Flag3])="Y",1))

    Then apply it into filter.

    The final show:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Thom_'s avatar
      Thom_
      Frequent Visitor

      Hi v-yalanwu-msft ,

       

      Thank you so much for this! 😁

       

      However, when I recreate this on my end I get an error saying Column 'xx' in table 'xxx' cannot be found or may not be used in this expression. I believe this is due to my Flag1, Flag2 and Flag3 columns being measures and not raw data for which it works in your example. I have recreated this and added it in the pbix you so kindly made. Is there a different but logically similar way to account for the fact my columns are measures?

      Link for the pbix file:

      https://www.dropbox.com/s/i7oedab5tsk0qnr/Field%20Parameters.pbix?dl=0

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, Thom_ ;

    Sorry for the late recovery.

    You could change it.

    filter2 = SWITCH(MAX(Parameter2[Parameter2]),"Fl1", IF( [Fl1]="Y",1),"Fl2", IF( [Fl2]="Y",1),"Fl3", IF([Fl3]="Y",1))

    The final show:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Thom_'s avatar
      Thom_
      Frequent Visitor

      Hi v-yalanwu-msft ,

       

      Thank you so much for this!! It works and I have accepted it as a solution 😄

  • Thom_ , Assume name of field parameter is axis slicer

     

    use this meausre in visual or visual level filter

     

    var _sel = maxx(filter('Axis Slicer', 'Axis Slicer'[Axis Slicer Order]= SELECTEDVALUE('Axis Slicer'[Axis Slicer Order])),'Axis Slicer'[Axis Slicer])
    var _filter = Switch(True() ,
    "Flag 1" , filter(Table, Table[Flag 1] = "Y"),
    "Flag 2" , filter(Table, Table[Flag 2] = "Y"),
    "Flag 3" , filter(Table, Table[Flag 3] = "Y")
    )
    return
    calculate(countows(Table), _filter)

     

     

    refer if needed

    https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9afd

  • Thom_'s avatar
    Thom_
    Frequent Visitor

    Hi Amit,

     

    Many thanks for this!!

     

    I try this measure however I get an error saying:

    Also the VAR _sel isn't referenced any further.