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 with Username() and multiple result values

Hi everyone,

 

I have a table "Email_BE" defining the access privilege. Users with a given email should have access to BUs listed:

 

111.JPG

 

 

 

 

 

 

 

 

 

 

 

I was able to make it work if there is only a single value in BUs:

[BU ID] = LOOKUPVALUE(Email_BE[BUs],Email_BE[UserEmailAdr],USERNAME())

 

However, I have a problem in getting the proper code to make it work with a list - I want to get the data for all the BUs the user in a member of. I want something like:

[BU ID] in LOOKUPVALUE(Email_BE[BUs],Email_BE[UserEmailAdr],USERNAME())

Any ideas? Many thanks up front! 😄

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try this one.

 

VAR A =
    CALCULATETABLE (
        VALUES ( Email_BE[BUs] ),
        FILTER ( Email_BE, Email_BE[UserEmailAdr] = USERNAME () )
    )
RETURN
    [BU ID] IN A

BTW, do mask your Confidential Information in your post. 🙂

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

7 REPLIES 7
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try this one.

 

VAR A =
    CALCULATETABLE (
        VALUES ( Email_BE[BUs] ),
        FILTER ( Email_BE, Email_BE[UserEmailAdr] = USERNAME () )
    )
RETURN
    [BU ID] IN A

BTW, do mask your Confidential Information in your post. 🙂

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

@v-frfei-msft 

Thanks for help. I did accept the solution, but afterwards I noticed that it works properly, only when a single value is available in BUs. I had to change the type of BU ID to text first, to make "IN" function work. Now, no errors are displayed, but it does not work as desired -if more then one value is present in BUs, than everything gets filtered out and all visualisations are (blank).

 

 

Hi @Anonymous ,

 

Kindly share your sample data to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

@v-frfei-msft 

Thank you! I have prepared a bare-bones version, that can be used for troubleshooting:

 

https://falck1-my.sharepoint.com/:u:/g/personal/adam_trzaskowski_falck_com/Ef2tKz2qEuFBo7AZahmJ_CAB_...

 

There are just 3 different users and some sample data for them.

Hi @Anonymous ,

 

To use this new one should work 🙂 please have a try.

 

VAR A =
    CALCULATE (
        CONCATENATEX ( Email_BE, Email_BE[BUs], "" ),
        FILTER ( Email_BE, Email_BE[UserEmailAdr] = USERNAME () )
    )
VAR b =
    SEARCH ( Org_Div_LoB_BU_Matrix[BU ID], A,, BLANK () )
RETURN
    b
    <> BLANK ()
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

 

@v-frfei-msft 

Unfortunately, it does not work. Am I making an error somewhere? Is it necessary to include the other table? 

Could you maybe share back the modified pbix file?

 

BU.JPG

Hi @Anonymous ,

 

In table Mitigations_Initiatives, we should use this formula.

VAR A =
    CALCULATE (
        CONCATENATEX ( Email_BE, Email_BE[BUs], "" ),
        FILTER ( Email_BE, Email_BE[UserEmailAdr] =USERNAME() )
    )
VAR b =
    SEARCH ( Mitigations_Initiatives[Business Entity ID],A,, BLANK () )
RETURN
    b
    <> BLANK ()

In aother one:

 

VAR A =
    CALCULATE (
        CONCATENATEX ( Email_BE, Email_BE[BUs], "" ),
        FILTER ( Email_BE, Email_BE[UserEmailAdr] =USERNAME() )
    )
VAR b =
    SEARCH ( Org_Div_LoB_BU_Matrix[BU ID], A,, BLANK () )
RETURN
    b
    <> BLANK ()

In your sample file, I user email address instead of username() to check the result. And seemed that to filter Org_Div_LoB_BU_Matrix is enough. Please check the pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

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.