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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

nandukrishnavs

Dynamic Page Navigation Based on User Login

For demonstration purposes, I have created two sample tables.

  1. Sales
  2. Role

Below is the Power Query for both tables.

 

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hZVBTsMwEEWvgroukmfsOPYFWLBFrEoXEXTBpkKQ+6shjeMf8ydUldpK7yeemTfp6XRw8ji91Uk+HA+v18/x8vHwMg7j5Wf6LZ2bXtOXPH+ej3debd4vvCLvbT4ufEA+2Hxe+Ih8Z/KhnCchH01e+zsvblNwbwZESmBTcbIDWgKbkrMd8CXgtQbE2YGwHilAwB7yPOU5IBEC9pQlrl1KUMPvHdTRAG+r2oG0zC1r45HBFy9SaDzivBav+9h4ZPBSvGsLnjv0Nj4PX8MVDTI2BsiijrErSOruliDpd/cDyX53M5BM+zuBaN7fBuyTYzVlRgqpqfqPtw+kJmFTqspjTULHFGlNq+ykp81uK0G79aqeGo5obSqVG9CwPiuEek08JTu8dODpe7i+XzZWWU4DWrSypAY0MQMCRTMZLGpd0eJVY2ukl43ssP1eXbbZleV/apmi7P8M3f6nB0LnxXsgdGBKn0JgN5wgsLqUoh17DnmGdnS2gaFVb9d68Idt/T7fAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Country = _t, Revenue = _t, #"Cost of Sales" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Country", type text}, {"Revenue", Int64.Type}, {"Cost of Sales", Int64.Type}})
in
    #"Changed Type"

 

 

 

1.JPG

 

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKi1OLTJ0SM1NzMzRS87PVdJRCs3LLElNUQguSSxJLVaK1YGoMUJR45VYkJgHlzNGkXMrSsxLToVLmqBIOubkKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Username = _t, Country = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Username", type text}, {"Country", type text}}),
    #"Trimmed Text" = Table.TransformColumns(#"Changed Type",{{"Country", Text.Trim, type text}})
in
    #"Trimmed Text"

 

 

 

role.JPG

 

These country names will be the page names in our report. We have to show only the default page(Home).

pages.JPG

 

Also, I have created two measures.

  • PageNavigation

 

 

PageNavigation = 
var _role= CALCULATE(SELECTEDVALUE(Role[Country]),FILTER(Role,Role[Username]=USERPRINCIPALNAME()))
return _role

 

 

 

Once the user login to the service, This PageNavigation measure will return the corresponding country name.

We can use this measure in the button Action destination field.

destination.JPGdest.JPG

 

  • RoleSpecificText

 

 

RoleSpecificText = 
var _role= CALCULATE(SELECTEDVALUE(Role[Country]),FILTER(Role,Role[Username]=USERPRINCIPALNAME()))
var _result= SWITCH(_role,"All","Detailed View","My View")
return _result

 

 

 

Once the user login to the service, this RoleSpecificText measure will return the dynamic button text value.

We can use this measure in the button text field.

button text.JPGbut.JPG

 

Let's see how it is working. 😎

 

Below is the view of User1.

user1.JPG

You can find the button text is "My View" (top right). When User1 clicks on My view, he will see United States data.

 

us1.JPG

 

Below is the view of User4.

user4.JPG

 

Now, the button text is "Detailed View". When User4 clicks on Detailed View, he will see detailed views of all country data.

us4.JPG

I have attached the pbix file for your reference. Try this feature and share your comments. 

Thank you 🙂

------------------------------------------------------------------------------------------------------------------------------------------

Comments
Anonymous

Thanks @nandukrishnavs. It is really helpful.

Anonymous

Useful Information @nandukrishnavs 

Anonymous

Good one @nandukrishnavs 

Cool, @nandukrishnavs, This was really informative. Great work. 👍

Similarly we can implement Page Level Security as well.

Refer to this blog by @mustafaasiroglu 

 

https://www.linkedin.com/pulse/page-tab-level-security-conditional-navigation-power-bi-a%25C5%259F%2...

 

 

@nandukrishnavs,

Nice I was looking for this, however I need smomething different I have 10 Pages so i want to add 10 Button in Home page but want to show few when user log in and remaining should show blank, can you please help me. Thanks

Regards

Suhel

@Suhel_Ansari You can place 10 buttons. Then conditionally format the button text, button fill color, and destination. If you don't want to show the last 5 buttons, just format the button text as blank, Destination as "None" and fill color as background color.

Basically buttons will be there, but the user will not be able to interact with that.

@nandukrishnavs, I could do that I need it dynamic based on the Roles as you did in this example, I am trying but not getting the end result, If a user has access to 5 Pages then 5 button should should Page1... Till Page5 and remaining should be blank. I would really appricate you Help. Thanks Regrads Suhel

This is excellent, thank you for sharing!

Very well thought.

I had a different senario and your post gave me a head start. For example, user1@email.com should be able to navigate to Japan and United States only whereas user2 should be allowed to navigate to United States and France.

 

I modified your pbix file and came up with a solution.

Keith_Fernandes_0-1619952075323.png

 

I used a slicer aligned in horizontal and button for page navigation.

Keith_Fernandes_1-1619952173005.png

Next I changed the page_navigation measure to the below and assign it to the button created for page nav-

Keith_Fernandes_2-1619952226429.png

Keith_Fernandes_4-1619952407989.png

 

In order to filter the data on the slicer I created a role-

Keith_Fernandes_3-1619952307418.png

 

After deploying the solution I assign users to the role. For test purpose I will manually assign username as user1@email.com in the solution itself.

Keith_Fernandes_5-1619952513141.pngKeith_Fernandes_6-1619952584054.png

 

Thank you.

Do check my other approach.

https://www.linkedin.com/posts/keithfernandes2195_powerbideveloper-powerbi-rls-activity-679378986848...