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
ORDR
Frequent Visitor

Calculated column checking the current RLS Role

Hello everyone, I'd like to add a calculated column to a table, setting TRUE or FALSE depending on the value of current role in use.
This table is not RLS filtered itself, but it must get some information from an other table contening a list of roles and which is filtered.

 

That seems simple but the problem is :

 

1) the DAX function ISFILTERED() doesn't detect that a table is RLS filtered;

 

2) PowerBi forbids you to use the USERNAME() function in a computed column (only in a measure - that is absurd), and it seems there is no function giving you the current role in use

 

3) apparently you cannot use a computed column (from an other table) to test the contents of RLS Filtered table (for example with IF() and CONTAINS() DAX functions).
It seems that during table load phase, the tables are first fully charged, and RLS filtering applies only after.
The result is that the computed column (checking for a certain role) allways returns TRUE, as during evaluation the RLS filtered table is found complete and not yet filtered.

 

This is not a simple issue. PowerBi Documentation is very poor about this subject.

Thank you in advance if someone has an idea.

2 REPLIES 2
darrenfishell
Advocate II
Advocate II

Fully agree, @ORDR

I am generally at a loss for something equivalent to Tableau's very clear description of its order of operations / query pipeline. I think this documentation will help clarify the nature of the question, @amitchandak: https://help.tableau.com/current/pro/desktop/en-us/order_of_operations.htm

I did some similar testing to try and discover whether RLS filtering would be applied before or after evaluation of a computed column, finding that the column evaluation happens first, then RLS filtering is applied. 

It would be great if this order were the other way around, which I think is also required to be able to use USERPRINCIPALNAME(), etc., within a computed column. 

This would be great to solve for use cases where you want to use a centralized data model but be able to customize reports to a degree for different users. This could reduce a lot of duplicate work and development, as one single data source and report could cater to a greater variety of audiences. 

 

In my particular use case, I want to populate a column DYNAMIC_DIMENSION with different dimensions based on who is logged in. Let's say if a top-level director is logged in, we want to show a bar chart broken out by Region and then a Regional Manager could be shown the breakout by offices. 

This could be achieved in a computed column, alongside RLS rules, to populate that DYNAMIC_DIMENSION column accordingly. That column would, of course, be used as the axis for the bar chart. 

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