Forum Discussion
Need help with RLS
- 1 year ago
Hi hichamou
To create a card that shows the SS for users with the role "ALL" and the Last4 for users with the role "Station", you can achieve this by creating a measure that uses conditional logic based on the user’s role.
Here’s how you can set it up in DAX, assuming you have relationships between the tables or have set up a way to identify the logged-in user:
Step 1: Create a Measure for Conditional Display
- Identify User Role: If you can identify the logged-in user, use their role from the Users Table.
- Create Conditional Measure: Use SWITCH or IF to conditionally display SS or Last4 based on the role.
DAX Measure
Assuming:
- DataTable is your main table with columns SS and Last4.
- Users Table contains User and Role.
- You can identify the current user with a function like USERNAME() or via another filter.
Here’s a sample DAX formula:
DisplayValue = VAR CurrentUser = SELECTEDVALUE('Users Table'[User]) VAR UserRole = LOOKUPVALUE('Users Table'[Role], 'Users Table'[User], CurrentUser) RETURN SWITCH( TRUE(), UserRole = "ALL", MAX('DataTable'[SS]), UserRole = "Station", MAX('DataTable'[Last4]), BLANK() )Explanation
- CurrentUser: Retrieves the currently logged-in user.
- UserRole: Uses LOOKUPVALUE to find the role of the current user in the Users Table.
- SWITCH:
- If the role is "ALL", it returns the SS value.
- If the role is "Station", it returns the Last4 value.
- If the role is neither, it returns blank.
Step 2: Add the Measure to a Card Visual
Add the DisplayValue measure to a card visual. Based on the role of the logged-in user, the card will display either the SS or Last4 value.
This setup should dynamically adjust based on the role associated with the user viewing the report. Let me know if you need further assistance!
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
YouTube: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
It worked, Thanks Poojara.
- Poojara_D121 year agoSuper User
hichamou Glad to hear that!! 🙂