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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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