Power BI — How to Create a Hidden Section with Conditional Access
Learn how to create a hidden section with multiple pages using a single measure in 5 simple steps.
As most of you probably already know, there is no PAGE RLS implemented in Power BI as of jun/24. If are part of the Fabric/Power BI Community you can support this idea here.
Page RLS
Sometimes implement an RLS in an already-in-production dashboard can be impracticable, due to multiples reasons as: existing RLS, lack of data, data modeling, filter directions…
So I recently figured out a simple way to create a Page RLS (multiple pages, or, henceforth “Section”) with a single measure.
How to
Step 1 — Username
Create a measure called user:
user = USERPRINCIPALNAME()
Using this function you’ll get the e-mail of the user.
Step 2 — Create the Tabs
In my case, I created 4 tabs: Page 1
, Page 2
, Hidden 1
and Hidden 2
. The hidden tabs will be called “Hidden Section” (in red) and the green will be called “Open Section”.
Step 4 — Create the another measure
The following measure will lead you to the hidden section of the dashboard.
Page Name =
var pagename = "Hidden 1" // Select the page name in the Hidden Section
var restricted = "no permission" // In case you are not allowed to enter the hidden section, another tab will be displayed.
return
if(
[user] == "teste@teste.com" // the e-mail of the person which will have access to the Hidden Section
// || [user] == "anyotheremail@teste.com"
// || [user] == "asmanyemailsasyouwant@teste.com"
,pagename
,restricted
)
Explaining the measure above
In the Page Name
measure we define two variables:
- pagename: which will lead us to the hidden section
- restricted: if the user is not allowed into the hidden section, he’ll directed to a tab telling him about it.
In the return we have a conditional, IF the USERPRINCIPALNAME() or E-MAIL is equal to a certain e-mail (that you’ll define) they will go to pagename variable, if don’t, it will lead them to the restriction page.
Step 5 — Button
Create any button you want
- Go to the format panel > action
- Select type as “Page navigation”
- Click in
fx
- Format style, choose: Field Value
- in “What field should we base this on”, select the measure:
Page Name
- Click ok, and it’s done!
Now let’s try it!
Go to the modeling > view as.
In Other user, write the e-mail as the following example:
Now click on “RESTRICTED AREA” and it will take you to “Hidden 1”.
Tips
Inside the “Hidden section” you’ll need to create buttons to navigate inside the hidden tabs and in the “Open Section” there will be only a single button to take you to the Hidden Section.
When you publish it into the Power BI Service the user will only be able to see the “Open Section” and the only way to get to the “Hidden Section” and navigate through it, will be using the buttons you created.
If you want to see the file (.pbix), here it is:
https://drive.google.com/file/d/1qwOACQWUmKVva2ae49Um64Qxah8SGxc0/view?usp=sharing
Igor Comune.
Don’t forget to subscribe to
and join our Power BI community