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.

Reply
TheracPowBi
Frequent Visitor

Use filters after user connection with PowerBi

Hi everybody,

I have an ASP.NET app in C#. When I launch it, a website is opened with a login page.

I want that, when a user enter his username and password and click on the "connection" Button",  my embed dashboard from powerBi is displayed and filtered, according on which user is connected.

 

I looked on this page https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/control-report-filters to use a basic filter but I don't know how to use them in my ASP.NET code.

 

Do you know where to put the different typescript codes and the JS code ( after I convert it in C#)  on my own code ?

 

Thanks 🙂

10 REPLIES 10
TheracPowBi
Frequent Visitor

Hi Hasham,

thanks for your answer.

I used the row-level security and when I arrived on the page to manage the roles, in the table filter DAX expression, I used the USERNAME() format. But does it mean that it will filter on the user currently connected to PowerBI ?

 

In my case, I have a database on SQL server with all the users, but they don't have a PowerBi account.

When the users will connect in my website, I will just verify if they are real users when they enter their username in a TextBox, and then verifying if this user exist in my database.

 

So, is this possible to use the filter with the username that the user wrote in the TextBox  ?

 

Thanks.

HashamNiaz
Solution Sage
Solution Sage

Hi @TheracPowBi !

 

You will need to implenent Row-Level secuirty in your Power BI Desktop report & configure it in Power BI Service.

 

Row Level Security 

 

Once you have done that in Power BI, you can use Power BI Embedded to call your Dashboards using UserName / Password.

 

Regards,

Hasham

Hi Hasham,

because the users that are on my SQL database don't have a Power Bi account, is it still possible to use the Row-level security ? Or is it better to use other filters like this one : https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/control-report-filters

Thanks.

@TheracPowBi 

 

I'm afraid it won't work. How can you connect to report without a powerbi account?

Actually I have a PowerBi account. What I was saying is that all the users that will connect in the website won't have a PowerBi account.

So, I only have one PowerBi account, necessary to embed my PowerBi report, and I want to filter my dashboard  depending on who is connecting on my website (but not on PowerBi).

 

To be more clear, In my database, I have a table with one of the column that is "contactname".

When a user connect in the website and enter his "username" in the textbox, I want to display only the rows where "contactname" = "username". 

So I have the same dashboard, with one PowerBi account, that is filtered depending on who is connected on the website.

I hope I was clear enough.

 

Thanks.

Hi, @TheracPowBi 

 

I understand what you mean, it should be impossible. This is equivalent to each user using your powerbi account to view the content, so there will be no way to implement RLS within the powerbi report. It does not support the way of interaction you want. If you set permissions at the data source level, it might be possible but his is something other than powerbi.

 

Best Regards,
Community Support Team _ Janey

Hi,

thanks for your answer.

So, because the RLS is not working in my case, is it possible to use the filters on this link https://docs.microsoft.com/en-us/javascript/api/overview/powerbi/control-report-filters ?

 

Instead of using a filter pane, is it possible to only use a "connexion" button and apply a filter on it ? The user would enter his login and password in the textboxes, then click the button, so it would filter on the login of the user.

I don't know if I can do it or if, like for the RLS, I need one PowerBi account for each user.

Thanks for your answer.

Hi, @TheracPowBi 

 

I'm not good at javascript, but I think if you can make the value in'values' match the user name that logs in to the program, It is possible to achieve.

vjaneygmsft_0-1641259943979.png

Best Regards,
Community Support Team _ Janey

Ok, I will try that.

I just have to know where to put the typescript and javascript codes in my program.

Do you have an idea on where to put them ?

Thanks.

@TheracPowBi 

 

The Power BI JavaScript support set filter when embedding. Check this:

Solved: how to create custom filters for power bi embedded... - Microsoft Power BI Community

Power BI - Sample - Client - JavaScript (microsoft.github.io)

 

Best Regards,
Community Support Team _ Janey

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.