Forum Discussion
how Can we pass USERPRINCIPLE or USERNAME as a query parameter in Power Query
- 2 years ago
I understand your needs but I think it's not possible. I can't figure out other solutions.
The only thing I can still suggest is to duplicate the semantic model, or make a specific dataflow for each developer, then each developer will connect to his own dataflow
Here is how can you achieve it.
1. Create a Security Table: Create a table in your database that maps users to their respective CompanyID through the email.
2. Import the table into Power BI
3. Create a relationship between the security table and the other table based on the CompanyId.
4. Implement Row-Level Security:
- Go to the Modeling tab in Power BI Desktop.
- Click on Manage Roles.
- Create a new role called RLS and then select DAX editor and set a DAX filter on the UserSecurity table to filter rows based on the logged-in user. Use the USERPRINCIPALNAME() function to get the emailid of the person.
5. Use the View as in the modelling tab and select the role and add the emailid to test the RLS.
That's how the data is viewed before RLS is implemented
That's how the data is viewed after RLS is implemented
6. Once it is done, you can publish it on the workspace. Go to the semantic model and then Select Security and the respective roles and add the emailid of the respective person in the security table to implement the RLS on power bi service.
If my post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Dear asadmd93:
Thanks for your reply. I know row level security is a good solution for report viewers. But what I refered is powerbi desktop developers, means that these developers has build access on the published semantic model, so when they connect to this semantic model they can get all data in this semantic model. That's why I ask for a solution via power query.