Forum Discussion

jbauti10's avatar
jbauti10
Advocate I
6 months ago
Solved

RLS Exclusionary Role with NOT PATHCONTAINS() Not Filtering Data

Hi,   I'm implementing Row-Level Security in Microsoft Fabric using embedded reports with a custom username string passed via the embed token identity. I have an exclusionary role that should block...
  • v-menakakota's avatar
    v-menakakota
    6 months ago

    Hi jbauti10 ,

    The issue turned out not to be related to Power BI Embedded, but rather to how NOT PATHCONTAINS() behaves inside Row Level Security (RLS). When the identity string parsing returns a blank or unexpected value, PATHCONTAINS() evaluates to FALSE, and wrapping it with NOT makes the overall expression TRUE for every row. As a result, no records get filtered out, which is why the exclusionary role appeared to not work.

     

    To fix this, the exclusion logic was rewritten using a more reliable pattern. Instead of relying on NOT PATHCONTAINS(), the pipe delimited values from USERPRINCIPALNAME() were converted into a table, and the filter was applied using NOT (Column IN Table Variable). This approach avoids the evaluation issue and works consistently within RLS. After applying this logic separately to both the Challenge and Community tables under the same role, and properly activating the role using View As - Other user in Power BI Desktop, the filtering worked as expected. With the test identity CHALLENGES=3696|3326;;COMMUNITIES=625;;EVALUATOR=135543, the Challenge table correctly excluded 3696 and 3326 (showing 3324, 3327, 5391, 51418), and the Community table correctly excluded 625 (showing 999999). This confirms that the behavior was due to how NOT PATHCONTAINS() evaluates in RLS, not a defect in embedding or the RLS engine.

     

    Please find the attached .pbix file for your reference.