cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kienzen87 Frequent Visitor
Frequent Visitor

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

Accepted Solutions
Community Support Team
Community Support Team

Re: Dynamic RLS with Username() and multiple result values

Hi @kienzen87 ,

 

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 other members find it more quickly.

View solution in original post

7 REPLIES 7
Community Support Team
Community Support Team

Re: Dynamic RLS with Username() and multiple result values

Hi @kienzen87 ,

 

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 other members find it more quickly.

View solution in original post

kienzen87 Frequent Visitor
Frequent Visitor

Re: Dynamic RLS with Username() and multiple result values

@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).

 

 

Community Support Team
Community Support Team

Re: Dynamic RLS with Username() and multiple result values

Hi @kienzen87 ,

 

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 other members find it more quickly.
kienzen87 Frequent Visitor
Frequent Visitor

Re: Dynamic RLS with Username() and multiple result values

@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.

Community Support Team
Community Support Team

Re: Dynamic RLS with Username() and multiple result values

Hi @kienzen87 ,

 

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 other members find it more quickly.
kienzen87 Frequent Visitor
Frequent Visitor

Re: Dynamic RLS with Username() and multiple result values

 

@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

Community Support Team
Community Support Team

Re: Dynamic RLS with Username() and multiple result values

Hi @kienzen87 ,

 

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 other members find it more quickly.

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 128 members 1,438 guests
Please welcome our newest community members: