Forum Discussion
show RLS Role name Currently being viewed on each sheet
I am using static row level security. I would like the ability create a card that shows the name of the role currently being viewed on the dashboard. My RLS is based on the Manager column below. It essentially states
if Manager [Column] contains “John” and “John/Jim” then John
if Manager [Column] contains “Jim” and “John/Jim” then Jim
if Manager [Column] contains “Bill” then “Bill”
| Manager | Role |
| John | John |
| John/Jim | John |
| John/Jim | Jim |
| Jim | Jim |
| Bill | Bill |
Hi Anonymous , sorry to know it didn't work for you. Please try below:
ActiveRole =
VAR CurrentRole = USERNAME()
RETURN
SWITCH(
CurrentRole,
"John", "John",
"Jim", "Jim",
"Bill", "Bill",
"No Role Assigned"
)If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
Thank you.
8 Replies
- Akash_Varuna
Super User
Hi Anonymous Create a DAX measure using SELECTEDVALUE to get the filtered Manager. Use a SWITCH statement to check conditions like "John" or "Jim" in the Manager column and return the corresponding role. Add this measure to a Card visual to display the active role.
- AnonymousNot applicable
thank you Akash_Varuna can you help me with the logic
- v-hashadapu
Community Support
Hi Anonymous , Thank you for reaching out to the Microsoft Community Forum.
Please try below DAX measure to display the current role based on your static Row-Level Security (RLS) setup. It also accounts for overlapping values like "John/Jim", handles blank or unexpected cases.
ActiveRole =
VAR SelectedManager = SELECTEDVALUE('YourTableName'[Manager], BLANK())
RETURN
SWITCH(
TRUE(),
ISBLANK(SelectedManager), "No Role Assigned",
SelectedManager = "Bill", "Bill",
SelectedManager IN {"John", "John/Jim"}, "John",
SelectedManager IN {"Jim", "John/Jim"}, "Jim",
"Unknown Role"
)
If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
Thank you.- AnonymousNot applicable
v-hashadapu thank you, this doesnt work the way I need it , as shown below I get no role assigned when I view as a manager that has multiple names that roll up to one manager. When a manager has only one name it works just fine.
- v-hashadapu
Community Support
Hi Anonymous , sorry to know it didn't work for you. Please try below:
ActiveRole =
VAR CurrentRole = USERNAME()
RETURN
SWITCH(
CurrentRole,
"John", "John",
"Jim", "Jim",
"Bill", "Bill",
"No Role Assigned"
)If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
Thank you.
- v-hashadapu
Community Support
Hi Anonymous , Thanks for the update. We are happy to hear that you have resolved the issue. Thanks for sharing the details here. Please mark your insights 'Accept as solution' to help others with similar problems find it easily.
Thank you. - v-hashadapu
Community Support
Hi Anonymous , I hope the information shared was helpful. If you have any additional questions or would like to explore the topic further, feel free to reach out. If any of the responses resolved your issue, please mark it "Accept as solution" and give it a 'Kudos' to support other members in the community.
Thank you! - v-hashadapu
Community Support
Hi Anonymous , Just checking in—were you able to resolve the issue?
If one of the replies helped, please consider marking it as "Accept as Solution" and giving a 'Kudos'. Doing so can assist other community members in finding answers more quickly.
Thank you!