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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
chat_peters
Helper III
Helper III

Filter to show the selected value and other rows based on a condition

I have the following table. When I select a name I want to return that Name and everyone who has a designation of staff. I know this might be a dynamic table. 

 

NameStaff/Client
HayesStaff
Billclient
Loganclient
Kendallstaff
Royclient
Shivstaff

 

I need help with this measure

 

 Staff Filter_Measure = CALCULATE(
    COUNTROWS('Clients and Staff'),
    FILTER(
        'Clients and Staff',
        'Clients and Staff'[Name] = SELECTEDVALUE('Clients and Staff'[Name])
    ),
  FILTER(ALL('Clients and Staff'[Client Staff Flag]),'Clients and Staff'[Client Staff Flag] = "Staff" 
    ))

 

1 ACCEPTED SOLUTION
hnguy71
Super User
Super User

Hi @chat_peters 

If you just want the count, then this should work:

Staff Filter_Measure = 

VAR _SelectedName = SELECTEDVALUE('Clients and Staff'[Name], "N/A")

VAR _Tbl = 
    ADDCOLUMNS(
        ALL('Clients and Staff'), 
        "@isValid", 
        SWITCH( TRUE(),
            [Staff/Client] = "Staff", 1,
            [Name] = _SelectedName, 1,
            0
        )
    )

RETURN

SUMX(_Tbl, [@isValid])


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

5 REPLIES 5
chat_peters
Helper III
Helper III

I apologize for the miscommunication. I don't want a count. If I create a filter with name field. When I pick a name I want a table showing that name and everybody with the staff designation. So for example the end result I am looking for is, if I picked Bill I want to see something like below

 

Name
Bill
Hayes
Kendall
Shiv

Hi,

Can you live with this?

Ashish_Mathur_0-1735964853693.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you so much for responding! I went with the solution posted by hbguy71. Thank you both for taking the time. I am going to hold on to the pbix file in the event I need this too

Hi @chat_peters 

Okay, understood, in that case, then you would adjust a few things...

You would need a disconnected table with the unique values of all the names. For simplicity sakes,

Names = DISTINCT('Clients and Staff'[Name])



Next, the measure needs to be modified to this instead:

Staff Filter_Measure = 

VAR _SelectedName = SELECTEDVALUE(Names[Name]) -- Get selected name from slicer
VAR _RowName = MAX('Clients and Staff'[Name]) -- Get current row name in the visual

// Filter for all names in scope
VAR _NamesInScope = 
CALCULATETABLE(
    VALUES('Clients and Staff'[Name]),
    'Clients and Staff'[Staff/Client] = "Staff" ||
    'Clients and Staff'[Name] = _SelectedName
) 

RETURN

// Check if current row name is in table output
IF(
    _RowName IN _NamesInScope,
    1,
    BLANK()
)
 

 
And lastly, on your visual, add the measure in and filter where value is 1 like so:

hnguy71_0-1735941243287.png

And this should be your final expected output:

hnguy71_1-1735941323887.gif

 

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
hnguy71
Super User
Super User

Hi @chat_peters 

If you just want the count, then this should work:

Staff Filter_Measure = 

VAR _SelectedName = SELECTEDVALUE('Clients and Staff'[Name], "N/A")

VAR _Tbl = 
    ADDCOLUMNS(
        ALL('Clients and Staff'), 
        "@isValid", 
        SWITCH( TRUE(),
            [Staff/Client] = "Staff", 1,
            [Name] = _SelectedName, 1,
            0
        )
    )

RETURN

SUMX(_Tbl, [@isValid])


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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