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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Watty
Regular Visitor

Complex RLS

Hi All

 

I have watched the following video and got this working great,

Summarising what I think is happening, Power BI is smart enough to know the schema and add on the extra where clause using the dax filter [column_name]=username ( where the username is passed in from the token )

 

Now our requirement for the retriction of data is more complex (sql below) is this possible ?

 

Help would really be appeciated for this.

 

https://channel9.msdn.com/Blogs/Seth-Juarez/Power-BI-Embedded-with-Josh-Caplan

 

;WITH RelationsCTE (ParentId, Id)
AS
(
SELECT
nodes_assigned_to_user.ParentId
,nodes_assigned_to_user.Id
FROM Client.Node AS nodes_assigned_to_user
WHERE
ISNULL(Root_Id, Id) = @ClientId
AND Id IN (
SELECT nur.Node_Id
FROM account.NodeUserRole nur
INNER JOIN account.UserRole ur ON nur.UserRole_Id = ur.Id
WHERE ur.[User_Id] = @UserId
)
UNION ALL
SELECT child_nodes.ParentId, child_nodes.Id
FROM Client.Node AS child_nodes
INNER JOIN RelationsCTE AS related_nodes
ON child_nodes.ParentId = related_nodes.Id
)

SELECT *
FROM client.Node
WHERE Node.Id IN (SELECT Id FROM RelationsCTE)

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@Watty,

 

DAX provides five functions to manage data that is presented as a parent-child hierarchy in models. You could take a look at it.

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

Hi Sam

 

Thanks for the reply.

 

When looking at this it looks like these are for reading a parent child releationship.

 

I am looking to restrict the rows processed by power bi in a similar way that [column]=usernam() adds on to the where clause

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Kudoed Authors