cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

dynamic RLS

hello I have this table with the accesses that each user must have.
furthermore i created this rule, however with use the maxx is only the last value is returned
example: user4@company.com should have access to "AAABBBCCCEEE" and "AAABBBCCCFFF".
with the current rule he only has access to "AAABBBCCCEEE".
Every help is welcome.
Thanks a lot for the help.
plaese apologize for my English

 

Emailaccess levelNameParentHierarchy
user1@company.comAAAAAA AAA
user2@company.comAAABBBBBBAAAAAA | BBB
user3@company.comAAABBBCCCCCCBBBAAA  | BBB | CCC
user4@company.comAAABBBCCCEEEEEECCCAAA | BBB | CCC | EEE
user4@company.comAAABBBCCCFFFFFFCCCAAA | BBB | CCC | FFF
user5@company.comAAABBBCCCHHHHHHCCCAAA | BBB | CCC | HHH

 

 

the rule

 

 

 

 

 

PATHCONTAINS(User[Hierarchy],
MaxX(
Filter(
User,
[Email]=USERPRINCIPALNAME()
)
,IF(User[Parent]="",User[Name],User[Name])
)
)

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: dynamic RLS

Hi @joaoar ,

 

As the formula in the link you refer to you should create:

 

 

Org Level 4 = LOOKUPVALUE (
    User[Email],
    User[Name],
    PATHITEM ( 'User'[Hierarchy], 4)
)

Org Level 3 = LOOKUPVALUE (
    User[Email],
    User[Name],
    PATHITEM ( 'User'[Hierarchy], 3)
)

Org Level 2 = LOOKUPVALUE (
    User[Email],
    User[Name],
    PATHITEM ( 'User'[Hierarchy], 2)
)

Org Level 1 = LOOKUPVALUE (
    User[Email],
    User[Name],
    PATHITEM ( 'User'[Hierarchy], 1)
)

 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

View solution in original post

9 REPLIES 9
Highlighted
Microsoft
Microsoft

Re: dynamic RLS

Hi @joaoar ,

 

I'm doubt why you use MAXX. Please try the followinng dax:

 

 

CALCULATE(IF(User[Parent]="",User[Name],User[Name]),Filter(User,[Email]=USERPRINCIPALNAME()))

 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

Highlighted
Helper I
Helper I

Re: dynamic RLS

hi @v-deddai1-msft 

i'm sorry i forgot to put PATHCONTAINS in the rule.
i need maxx because of PATHCONTAINS.
is there any other solution?
Thanks in advance

Highlighted
Helper I
Helper I

Re: dynamic RLS

hi @amitchandak 

Thanks for your help but it didn't work.
i followed this toturial https://radacad.com/dynamic-row-level-security-with-profiles-and-users-in-power-bi but it doesn't work because it doesn't use hierarchy.

that is, user user1@company.com must see all records. the user user3@company.com should see everything below him (and himself) and the user user5@company.com should only see himself.
any idea how to do this?
thank you very much

Highlighted
Super User IV
Super User IV

Re: dynamic RLS

@joaoar , have you checked this one. 

https://www.blue-granite.com/blog/using-dynamic-row-level-security-with-organizational-hierarchies



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Helper I
Helper I

Re: dynamic RLS

hi @amitchandak 

I've been following the tutorial. I do not want to give access by the number of employees but by the level of access. so I had to make some changes to the tuturial formula,
as the LOOKUPVALUE function does not support comparisons between texts it is not possible to follow the toturial.
thanks for your help.
Any idea how to continue?

 

formula in toturial:

 

Org Level 4 = LOOKUPVALUE (
    'Organization'[Email - Work],
    'Organization'[Employee ID],
    PATHITEM ( 'Organization'[Organizational Hierarchy], 4, 1 )
)

my formula:

Org Level 4 = LOOKUPVALUE (
    User[Email],
    User[last nivel],
    PATHITEM ( 'User'[Hierarchy], 4, 1 )
)


last nivel = IF(User[Parent]="",User[Name],User[Name])
Highlighted
Microsoft
Microsoft

Re: dynamic RLS

Hi @joaoar ,

 

As the formula in the link you refer to you should create:

 

 

Org Level 4 = LOOKUPVALUE (
    User[Email],
    User[Name],
    PATHITEM ( 'User'[Hierarchy], 4)
)

Org Level 3 = LOOKUPVALUE (
    User[Email],
    User[Name],
    PATHITEM ( 'User'[Hierarchy], 3)
)

Org Level 2 = LOOKUPVALUE (
    User[Email],
    User[Name],
    PATHITEM ( 'User'[Hierarchy], 2)
)

Org Level 1 = LOOKUPVALUE (
    User[Email],
    User[Name],
    PATHITEM ( 'User'[Hierarchy], 1)
)

 

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

View solution in original post

Highlighted
Helper I
Helper I

Re: dynamic RLS

hi @v-deddai1-msft 

 

Thank you so much for your answer.


it solves the problem if I have a user for each access level. but if I want user123@company.com and user1@company.com to have AAA access level I get this error "A table of multiple values was supplied where a single value was expected."

 

Emailaccess levelNameParentHierarchy
user123@company.comAAAAAA AAA
user1@company.comAAAAAA AAA

 

can you help please?
thank you very much

 

Highlighted
Microsoft
Microsoft

Re: dynamic RLS

Hi @joaoar ,

 

When you use looupvalue, if multiple values are returned, this error will be reported under one filter condition. And you can use firstnonblank function.

 

Please refer to https://community.powerbi.com/t5/Desktop/LOOKUPVALUE-quot-A-table-of-multiple-values-was-supplied-wh...

 

Best Regards,

Dedmon Dai

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Community Summit Australia – Join Online!

Community Summit Australia – Join Online!

Be a part of the leading Microsoft Business Applications digital event, curated for the APAC community.

Top Solution Authors
Top Kudoed Authors