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

Dynamic row-level security

I have successfully created a role in Power BI to control access to the content of my report using the DAX script below:

 

SWITCH(

       TRUE(),

       [SecuredAccessType] = "Full Access", 1=1,

       [SecuredAccessType] = "Standard Access", 1=1,

       [SecuredAccessType] = "Limited Access" && [SecuredOfficeGroupAccessType] = "See Data of All Office Groups", 1=1,

       [SecuredAccessType] = "Limited Access" && [SecuredOfficeGroupAccessType] <> "See Data of All Office Groups", DimOriginatingOffice[Office Group] = [SecuredOfficeGroup],

       1=1

       )

 

I have now been told that under some conditions, it would be great if they can turn the role on and off. I have created slicer with two values to handle this – Secured and Unsecured.I also created a Measure to capture the selected value of the slicer as shown below:

 SecuredMode = SELECTEDVALUE('Report Mode'[ReportMode])

 

I then simply wrapped a simple IF statement around my DAX to handle this as shown below:

 

IF ([SecuredMode] = "Secured",

SWITCH(

       TRUE(),

       [SecuredAccessType] = "Full Access", 1=1,

       [SecuredAccessType] = "Standard Access", 1=1,

       [SecuredAccessType] = "Limited Access" && [SecuredOfficeGroupAccessType] = "See Data of All Office Groups", 1=1,

       [SecuredAccessType] = "Limited Access" && [SecuredOfficeGroupAccessType] <> "See Data of All Office Groups", DimOriginatingOffice[Office Group] = [SecuredOfficeGroup]

             ), 1=1)

 

 To my surprise, it appears that my slicer selection does not get recognised as no matter how many times I change the selection, my role expression always resolve to the default value of my IF statement.

 

 

Is this a limitation in POWER BI or am I doing something wrong?

Helpful resources

Announcements
Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

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