Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
94veiga
Helper II
Helper II

Advanced Filtering

Hello!! I have a table like this one:

 

WorkerDepartment
PeterMarketing
JaimeMarketing
PeterAccounting
AlexHuman Resources
MariaAccounting

 

I want to filter for example by department so if I select Marketing department the result would be Peter and Jaime. Also I want to filter by worker so if I choose Peter the result has to be María as they work in the same department.

 

Is this posible?

 

Thanks in advanced!!

1 ACCEPTED SOLUTION

Hi @94veiga ,

 

Create a new table based on your original table for slicer:

 

Table2 = UNION(SELECTCOLUMNS('Table',"Category","Worker","Value",'Table'[Worker]),SELECTCOLUMNS('Table',"Category","Department","Value",'Table'[Department]))

Capture27.PNG

 

Then create two slicers using the new column from the new table, and add visual level filter to them:

Capture28.PNG

 

Then you can use the following measure:

Measure =
IF (
    ISFILTERED ( Table2[Value] ),
    SWITCH (
        MAX ( Table2[Category] ),
        "Worker",
            VAR A =
                CALCULATETABLE (
                    VALUES ( 'Table'[Department] ),
                    FILTER ( 'Table', 'Table'[Worker] = MAX ( Table2[Value] ) )
                )
            RETURN
                CONCATENATEX (
                    EXCEPT (
                        CALCULATETABLE (
                            VALUES ( 'Table'[Worker] ),
                            FILTER ( 'Table', 'Table'[Department] IN A )
                        ),
                        VALUES ( Table2[Value] )
                    ),
                    'Table'[Worker],
                    ","
                ),
        "Department",
            CONCATENATEX (
                CALCULATETABLE (
                    VALUES ( 'Table'[Worker] ),
                    FILTER ( 'Table', 'Table'[Department] IN VALUES ( Table2[Value] ) )
                ),
                'Table'[Worker],
                ","
            )
    ),
    CONCATENATEX ( VALUES ( 'Table'[Worker] ), 'Table'[Worker], "," )
)

 

test2.gif

 

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

 

Best Regards,

Dedmon Dai

 

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@94veiga , for that is better you need an independent table with names

 

measure =

var _tab = summarize(filter(Table, Table[Worker] in allselected(Worker[Worker])), Table[Department])
return
calculate(counrows(Table), filter(Table, Table[Department] in _tab))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for your time! I tried to do what you've told me but I think I didn't get it. It is giving me the number of people he is working with but not the rest of the info.

 

Thanks again

Hi @94veiga ,

 

Create a new table based on your original table for slicer:

 

Table2 = UNION(SELECTCOLUMNS('Table',"Category","Worker","Value",'Table'[Worker]),SELECTCOLUMNS('Table',"Category","Department","Value",'Table'[Department]))

Capture27.PNG

 

Then create two slicers using the new column from the new table, and add visual level filter to them:

Capture28.PNG

 

Then you can use the following measure:

Measure =
IF (
    ISFILTERED ( Table2[Value] ),
    SWITCH (
        MAX ( Table2[Category] ),
        "Worker",
            VAR A =
                CALCULATETABLE (
                    VALUES ( 'Table'[Department] ),
                    FILTER ( 'Table', 'Table'[Worker] = MAX ( Table2[Value] ) )
                )
            RETURN
                CONCATENATEX (
                    EXCEPT (
                        CALCULATETABLE (
                            VALUES ( 'Table'[Worker] ),
                            FILTER ( 'Table', 'Table'[Department] IN A )
                        ),
                        VALUES ( Table2[Value] )
                    ),
                    'Table'[Worker],
                    ","
                ),
        "Department",
            CONCATENATEX (
                CALCULATETABLE (
                    VALUES ( 'Table'[Worker] ),
                    FILTER ( 'Table', 'Table'[Department] IN VALUES ( Table2[Value] ) )
                ),
                'Table'[Worker],
                ","
            )
    ),
    CONCATENATEX ( VALUES ( 'Table'[Worker] ), 'Table'[Worker], "," )
)

 

test2.gif

 

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

 

Best Regards,

Dedmon Dai

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors