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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rajanikantxp
New Member

RLS query with Multiple columns, Columns differ basis of condition.

Query1: Need to put RLS on the basis of Country,TeamName,Process in the Main Table.

Another Table called UserMapping where we have Email,Country,TeamName,Process, Role (basis of role we have to take Country&TeamName,TeamName&Process, Only Country etc.

 

Here I put RLS on UserMapping to know the Role,Country,TeamName,Process, So that I can filter our Main Table.

Query2: How can we store UserprincipalName() in the Table or Somewhere else so that I can use username in our Main Table/Column. (UserprincipalName() can not support in Table/Column).

1 ACCEPTED SOLUTION
rajanikantxp
New Member

Solved:  

  • On the basis of Email, I already done for both (Main Table and UserMapping)
  • But my case is different from point 1, there is no relation.

What I did here,

  • Output from UserMapping on the basis of Email (like Country,Team,Process,Combination of Country and Team,Combination of Team and Process etc.)
  • Get desire output from Main Table on the basis of Point 1 (Output)
  • As there are no relation between these tables, what I did, Consider UserMapping Output as a Input for Main Table.

Syntax : Manage Role sections only.

VAR _upn=USERPRINCIPALNAME()

VAR _Country='Main Table'[Country] IN CALCULATETABLE(VALUES(' UserMapping '[Country]),' UserMapping '[EMail]=_upn)

VAR _CountryAndProcess='Main Table'[CountryAndProcess] IN CALCULATETABLE(VALUES('UserMapping'[CountryAndProcess]),' UserMapping '[EMail]=_upn)

VAR _None='Main Table'[CountryAndTeam] IN CALCULATETABLE(VALUES('UserMapping'[CountryAndTeam]),' UserMapping '[EMail]="None")

return

IF(_TypeMapping="ABC" && CONTAINSSTRING([_RoleMapping],"Manager")  ,_Country

,IF(_TypeMapping="XYZ" && (CONTAINSSTRING([_RoleMapping],"Country Head") || CONTAINSSTRING([_RoleMapping],"Developer"))        ,_CountryAndProcess,_None))

View solution in original post

2 REPLIES 2
rajanikantxp
New Member

Solved:  

  • On the basis of Email, I already done for both (Main Table and UserMapping)
  • But my case is different from point 1, there is no relation.

What I did here,

  • Output from UserMapping on the basis of Email (like Country,Team,Process,Combination of Country and Team,Combination of Team and Process etc.)
  • Get desire output from Main Table on the basis of Point 1 (Output)
  • As there are no relation between these tables, what I did, Consider UserMapping Output as a Input for Main Table.

Syntax : Manage Role sections only.

VAR _upn=USERPRINCIPALNAME()

VAR _Country='Main Table'[Country] IN CALCULATETABLE(VALUES(' UserMapping '[Country]),' UserMapping '[EMail]=_upn)

VAR _CountryAndProcess='Main Table'[CountryAndProcess] IN CALCULATETABLE(VALUES('UserMapping'[CountryAndProcess]),' UserMapping '[EMail]=_upn)

VAR _None='Main Table'[CountryAndTeam] IN CALCULATETABLE(VALUES('UserMapping'[CountryAndTeam]),' UserMapping '[EMail]="None")

return

IF(_TypeMapping="ABC" && CONTAINSSTRING([_RoleMapping],"Manager")  ,_Country

,IF(_TypeMapping="XYZ" && (CONTAINSSTRING([_RoleMapping],"Country Head") || CONTAINSSTRING([_RoleMapping],"Developer"))        ,_CountryAndProcess,_None))

lbendlin
Super User
Super User

What is the question for Query1?

 

For Query2:  You need to decide if you want to do static RLS (based on role membership) or dynamic RLS (based on USERPRINCIPALNAME).  If you data already has an email address field in a dimension table then you can add the RLS rule to that table.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.