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
szymon_zabiello
Regular Visitor

RLS on database level with Direct Query

Here is the scenario.
Source: Teradata 
Connection mode in Power BI: Direct
Requirement: Identify the user logged in, by USERPRINCIPALNAME() function and pass its value to the direct query, in order to filter the data.

Ideal solution: Pass the value of measure User_Id = USERPRINCIPALNAME() to Power Query parameter, so that it would go to my WHERE clause as a parameter and filter the data.

So far, I did not find a solution. Is it even possible?

 

1 ACCEPTED SOLUTION

Hi @szymon_zabiello ,

Currently any measures and calculated columns could not be quoted in power query.

You can try to configure RLS directly in the data source side. Refer: Row-Level Security 

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
szymon_zabiello
Regular Visitor

Hi @lbendlin 

So, you're referring to "If you're using DirectQuery, the security roles in your data source are used. When a user opens a report Power BI sends a query to the underlying data source, which applies security rules to the data based on the user's credentials."

How does it fit into such case?

 

1. I've got a table UserRoles

UserId | RoleId

1234   | 1

3456.  | 2

  ...      | ...

 

2. Table FactData

Column 1 | ... | RoleId

Value 1.    | ... | 1

Value 2.    | ... | 2

    ....         | .... | ...

 

3. I've got a measure User = USERPRINCIPALNAME() that is returning the logged user

 

4. My Power Query is sth like

select * from FactData f

join UserRoles u on f.RoleId = u.RoleId

where UserId = @LoggedUserId

 

Question, how do I pass the measure User that is defined in PBI Desktop, to the query in Power Query? 

Hi @szymon_zabiello ,

Currently any measures and calculated columns could not be quoted in power query.

You can try to configure RLS directly in the data source side. Refer: Row-Level Security 

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Why would you need that? The database already knows which user is running the direct query?

Row-level security (RLS) with Power BI - Power BI | Microsoft Docs

Last FAQ.

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.

Top Solution Authors