Forum Discussion

Salva_BI_DAX's avatar
Salva_BI_DAX
Regular Visitor
3 years ago
Solved

Show row based on slicer value

Hi everyone,

 

I am still bit new here, and I woul like your help on this.

 

I have a table like this:

IDName
1A
1AA
1AAA
2B
2BB
2BBB
3C
3CC

 

I have a filter that show all Names, if I select AA I need to see this

IDName
1A
1AA
1AAA

 

and if I select C I need to see this

IDName
1A
1AA
1AAA

 

I tried to create a flag like this but it does not work

_slicer =

CALCULATE (
DISTINCTCOUNT ( tmp[id] ),
FILTER (
ALL ( tmp ),
tmp[id] = SELECTEDVALUE(tmp[id])
)
)
 
Thanks,
Salva

 

Best,

Salvatore 

  • Hi , Salva_BI_DAX 

    According to your description, you want to have a [Name] filter and when you select a name, and show all the same id and the names. RIght?

    Here are the steps you can refer to :

    (1)My test data is the same as yours.

    (2)We need to click "New Table" to create a table :

    Slicer = VALUES('Table'[Name])

    (3)We need to create a measure :

    Measure = var _slicer = VALUES(Slicer[Name])
    var _t =DISTINCT( SELECTCOLUMNS(FILTER(ALLSELECTED('Table'), 'Table'[Name] in _slicer),"ID",[ID]))
    var _current_id = SELECTEDVALUE('Table'[ID])
    return
    IF(_current_id in _t ,1,0)

    (4)Then we can put the 'Slicer'[Name] on the slicer visual and the field we need on the table visual , and configue the measure on the "Filter on this visual":

    If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

     

3 Replies

  • Hi , Salva_BI_DAX 

    According to your description, you want to have a [Name] filter and when you select a name, and show all the same id and the names. RIght?

    Here are the steps you can refer to :

    (1)My test data is the same as yours.

    (2)We need to click "New Table" to create a table :

    Slicer = VALUES('Table'[Name])

    (3)We need to create a measure :

    Measure = var _slicer = VALUES(Slicer[Name])
    var _t =DISTINCT( SELECTCOLUMNS(FILTER(ALLSELECTED('Table'), 'Table'[Name] in _slicer),"ID",[ID]))
    var _current_id = SELECTEDVALUE('Table'[ID])
    return
    IF(_current_id in _t ,1,0)

    (4)Then we can put the 'Slicer'[Name] on the slicer visual and the field we need on the table visual , and configue the measure on the "Filter on this visual":

    If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

     

    • Salva_BI_DAX's avatar
      Salva_BI_DAX
      Regular Visitor

      I did a test and it worked just fine.
      Thank you 🙂

  • daXtreme's avatar
    daXtreme
    Icon for Solution Sage rankSolution Sage

    I think it would be highly advisable that before you post a question you check it for mistakes and logical inconsistencies...