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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

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

Hi @Anonymous ,

 

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

11 REPLIES 11
Abilaash98
Frequent Visitor

Hi Joaoar,

 

I had similar requirement and below is how I solved it.

 

EmailAccess LevelNameHierarchyRole_OrderFirst_RoleSecond_Role
user1@company.comAAABBBBBBAAA | BBB1BBB 
user2@company.comAAABBBCCCCCCAAA | BBB | CCC1CCC 
user3@company.comAAABBBCCCEEEEEEAAA | BBB | CCC | DDD | EEE1EEE 
user3@company.comAAABBBCCCFFFFFFAAA | BBB | CCC | FFF2 FFF

 

Role_Order: New column using Power Query editior. (Link: https://youtu.be/7CqXdSEN2k4)

First_Role: Calculated column Dax: If(Role_Order = 1,Name).

Second_Role: Calculated column Dax: If(Role_Order = 2,Name).

 

RLS:

 

PATHCONTAINS(User[Hierarchy],

Maxx(

Filter(

User,

[Email]=USERPRINCIPALNAME()

)

, User[First_Role]

)

) | |

PATHCONTAINS(User[Hierarchy],

Maxx(

Filter(

User,

[Email]=USERPRINCIPALNAME()

)

, User[Second_Role]

)

)

 

Thanks.

Anonymous
Not applicable

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

Anonymous
Not applicable

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])

Hi @Anonymous ,

 

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

Anonymous
Not applicable

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

 

Hi @Anonymous ,

 

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-where-a/td-p/331656

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

Hello @v-deddai1-msft 
I apologize for the delay in replying but I was on vacation so I didn't have access to my account.
i understand i can't use looupvalue but what should i use. I need several users to have the same level of access. Please help me.
thank you

v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

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

Anonymous
Not applicable

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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