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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
planbitionbi
Frequent Visitor

Row level security with user email -> Multiple User ID with same e-mail to filter on

Hi all!

 

I have succesfully implemented row level security using the guide:

https://www.youtube.com/watch?v=Sge_g9hTXWE&feature=emb_logo&ab_channel=PragmaticWorks

 

Now the only issue is that I can have multiple users (userID's) with the same email adress and my DAX Filter on the table I have implemented RLS on expects a singel UserID. How can I change this DAX Formula in a way that multiple USerID's can be the input of the filter.

 

DAX Formule on my CustomerStructure table:

[ID] IN SELECTCOLUMNS(
FILTER(
Security_User_CustomerStructure,
Security_User_CustomerStructure[PersonID] = LOOKUPVALUE(Security_Users[PersonID], Security_Users[Email], USERNAME() )
),
"ID", [CustomerStructureID]
)

 

Printscreens:

planbitionbi_0-1610442260722.pngplanbitionbi_1-1610442287192.png

 

 

1 ACCEPTED SOLUTION

Hi @planbitionbi ,

 

Please refer to the following measure:

[ID]
        IN SELECTCOLUMNS (
            FILTER (
                Security_User_CustomerStructure,
                Security_User_CustomerStructure[PersonID]
                    IN CALCULATETABLE (
                        VALUES ( Security_Users[PersonID] ),
                        FILTER ( Security_Users, Security_Users[Email] = USERPRINCIPALNAME () )
                    )
            ),
            "ID", [CustomerStructureID]
        )

 

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

3 REPLIES 3
planbitionbi
Frequent Visitor

Hi!

 

Thanks a lot for your feedback. Unfortunately it's throwing an error like below. Can you see why it's wrong? Something with the IN clause:

 

planbitionbi_0-1610615667143.png

 

Hi @planbitionbi ,

 

Please refer to the following measure:

[ID]
        IN SELECTCOLUMNS (
            FILTER (
                Security_User_CustomerStructure,
                Security_User_CustomerStructure[PersonID]
                    IN CALCULATETABLE (
                        VALUES ( Security_Users[PersonID] ),
                        FILTER ( Security_Users, Security_Users[Email] = USERPRINCIPALNAME () )
                    )
            ),
            "ID", [CustomerStructureID]
        )

 

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

v-deddai1-msft
Community Support
Community Support

Hi @planbitionbi ,

 

I suggest you use USERPRINCIPALNAME ( ) instead of USERNAME() and you can change the dax to :

 

[ID] IN SELECTCOLUMNS(
FILTER(
Security_User_CustomerStructure,
Security_User_CustomerStructure[PersonID] IN CALCULATETABLE(VALUES(Security_Users[PersonID]),FILTER(Security_Users,Security_Users[Email] = USERPRINCIPALNAME())),
"ID", [CustomerStructureID]
)

 

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.