cancel
Showing results for 
Search instead for 
Did you mean: 

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

Thanks @nandukrishnavs. It is really helpful.

Useful Information @nandukrishnavs 

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