Forum Discussion
DRLS in Multiple columns
- 3 years ago
Hi Pragadeesh_M ,
Interesting set-up.
Typically you would build RLS against dimension tables but seems you have all your data into one flat table. However, to accomplish this with your current model you'll have to ensure you disconnect the two tables.
To make things easier, you'll need to create a key column in both your Main and User tables. The key will be your primary 3 columns you want to check against: branch, produce, and vehicle. Something like this:
Access.Key = COMBINEVALUES("^", [Branch Code], [Product Code], [Vehicle Type])And then within your Manage Roles configuration, the DAX expression against your Main table would similar to this:
VAR _UPN = USERPRINCIPALNAME() VAR _isMaster = COUNTROWS(CALCULATETABLE(YOUR_USER_TABLE, YOUR_USER_TABLE[User Mail] = _UPN, YOUR_USER_TABLE[Access Level] = "M")) >= 1 VAR _IAM = IF( _isMaster, TRUE(), [Access.Key] IN CALCULATETABLE(VALUES(YOUR_USER_TABLE[Access.Key]), YOUR_USER_TABLE[User Mail] = _UPN)) RETURN _IAMOf course, you'd replace YOUR_USER_TABLE with your actual table name.
Hi Pragadeesh_M ,
Interesting set-up.
Typically you would build RLS against dimension tables but seems you have all your data into one flat table. However, to accomplish this with your current model you'll have to ensure you disconnect the two tables.
To make things easier, you'll need to create a key column in both your Main and User tables. The key will be your primary 3 columns you want to check against: branch, produce, and vehicle. Something like this:
Access.Key = COMBINEVALUES("^", [Branch Code], [Product Code], [Vehicle Type])
And then within your Manage Roles configuration, the DAX expression against your Main table would similar to this:
VAR _UPN = USERPRINCIPALNAME()
VAR _isMaster = COUNTROWS(CALCULATETABLE(YOUR_USER_TABLE, YOUR_USER_TABLE[User Mail] = _UPN, YOUR_USER_TABLE[Access Level] = "M")) >= 1
VAR _IAM = IF( _isMaster, TRUE(), [Access.Key] IN CALCULATETABLE(VALUES(YOUR_USER_TABLE[Access.Key]), YOUR_USER_TABLE[User Mail] = _UPN))
RETURN
_IAM
Of course, you'd replace YOUR_USER_TABLE with your actual table name.
- Pragadeesh_M3 years agoRegular Visitor
Hi. hnguy71. It worked perfectly. Thank you so much