Forum Discussion

Irek's avatar
Irek
Helper II
2 years ago
Solved

Filtering table by other table,

I have such table, need have functionality that allows me to filter it by slicer in such way that when I choose name for example Bob , my visualistion will show all rows where Bob appears in Key colu...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, Irek 

    First, create a new table:

    Table 2 = SELECTCOLUMNS('Table',"Name2",'Table'[Name])

     

    Then create a new measure and try the following DAX:

    Measure = 
    VAR _Slicer =
        VALUES ( 'Table 2'[Name2])
    VAR _vtable =
        ADDCOLUMNS (
            GENERATE ( 'Table', _Slicer ),
            "AAA", IF ( FIND ( [Name2], [Key],, BLANK () ) <> BLANK (), [Name2] )
        )
    VAR _vtable2 =
        SUMMARIZE (
            _vtable,
            [Key],
            "BBB",
                IF (
                    LEN ( CONCATENATEX ( _Slicer, [Name2] ) )
                        = LEN (
                            CONCATENATEX ( FILTER ( _vtable, [Key] = EARLIER ( [Key] ) ), [AAA] )
                        ),
                    CONCATENATEX ( FILTER ( _vtable, [Key] = EARLIER ( [Key])), [AAA] )
                )
        )
    RETURN
    
        IF (
            CONCATENATEX ( FILTER ( _vtable2, [Key] = 'Table'[Key]), [BBB] )
                <> BLANK (),
            CONCATENATEX ( FILTER ( _vtable2, [Key] = 'Table'[Key] ), [BBB] )
        )
    

    When you select Bob, here is preview:

     

    Then select Adam:

     

    How to Get Your Question Answered Quickly

    Best Regards

    Yongkang Hua

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