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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
a1b1c1
Advocate I
Advocate I

Custom Implemention for RLS using PATH()

Hi,
I've got quite a unique scenario over here involving RLS implementation. 

If you take a look at the sample data, it's the case that for individual users e.g. user1, I have corresponding manager information and I'm able to calculate the heirarchy in Path column using DAX PATH() function. 
The problem lies with the rows where essentially users are merged in form of teams e.g. "user1/user2" and they may have different managers. As a starter, I created Calculated Username to get usernames from individual users (how? long story.)
Now, I need to create a column as portrayed in Calculated Path. 

Sample Data: 

UserUsernameCalculated UsernamePathCalculated Path (Desired column) 
user1user1@company.comuser1@company.comManager1 | user1Manager1 | user1 
user2user2@company.comuser2@company.comManager2 | user2Manager2 | user2 
user1/user2nulluser1@company.com;user2@company.comnullManager1 | user1; Manager 2 | user2 


Furthermore, I found this code by @TomMartens from https://community.powerbi.com/t5/Desktop/DAX-forumula-help-with-comma-separated-values/m-p/534837
//Awesome job on the code btw.


Column =
var stringSelected = FIRSTNONBLANK('Consolidated Sales Rep Table'[Calculated Username],0)
var stringAsPath = SUBSTITUTE(stringSelected,";","|")
var intPathLength = PATHLENGTH(stringAsPath)+0
var tempTable =
          SELECTCOLUMNS(
                ADDCOLUMNS(
                     GENERATESERIES(1,intPathLength)
                     ,"Users",PATHITEM(stringAsPath,''[Value],TEXT)
                 )
           ,"Users", [Users]
         )
return
CONCATENATEX(temp,[New Path],"|")

What this code does is, is that it separates delimeter based strings and creates a temporary table and stores individual strings in rows, pretty neat stuff!

How I am trying to leverage it: 
By adding one more variable to the code:

var PleaseDearGod = FILTER('myTable', 'myTable'[Username] IN {tempTable})
return CONCATENATEX( PleaseDearGod, Path], "|" )
// It would check "user1@company.com" & "user2@company.com" (in form of two rows) and filter the table where they have their individual user data and fetch Path column.


The issue with this approach seems to be the splitting of Calculated Username into two rows, which generates "A table of multiple values was supplied error where a single value was expected."
 
Could you please help me out in this? I'd highly appreciate it.
@TomMartens @parry2k @Greg_Deckler @PhilipTreacy 



1 REPLY 1
v-robertq-msft
Community Support
Community Support

Hi, @a1b1c1 

According to your description and DAX formula, I can not find the real reason and true location that the error occurs. Would you like to post your test pbix file(without sensitive data) and your expected result so that we can help you in advance?

Thanks very much!

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.