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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Surekha
Helper I
Helper I

Split a string of values into Columns

Hi All,

I am using Embeded power BI, in the Username() i am getting list of values "A,B,C,D". When i am reading this it is considering as a string not as a list of values. Anyone come accross this situation, where i need to put this into a table as list of values and use that column in the RLS then my data gets filtered. Really facing very challenging. OR Is there any alternative ways to read the access token can retrieve the list of values and store those values? really very tricky. Your suggestion and guidence much appreciated.

 

1 ACCEPTED SOLUTION

Hi Tamerj,

i have created a measure same as mentioned.  I assume that it returns the table but somehow i am not able to see any thing. Do i need to create any table prior to this?

RLS_Key =
VAR String = "P1,P2,P3" -- place your sting here
VAR Items =SUBSTITUTE ( String, ",", "|" )
VAR Length =COALESCE ( PATHLENGTH ( Items ), 1 )
VAR T1 =GENERATESERIES ( 1, Length, 1 )
RETURN
SELECTCOLUMNS (T1,"Project",PATHITEM(Items,[Value]))
 
Could you please clarify.

 

View solution in original post

9 REPLIES 9
tamerj1
Super User
Super User
tamerj1
Super User
Super User

Hi @Surekha 

please provide one clear example of what are you trying to achieve. 

Hi Tamerj1, Thanks for responding. I am using Embeding Power BI. In that we are using RLS. In general secenarios, RLS works based on Username(), Userprincipalname() where it will return either user name or user email id. With embeded power BI RLS scenario, we can get any value in the username() as part of the requirement on which value we should filter the data. As part of RLS, i am getting a string with list of values where user can see the report only with list of values corresponding data. Here string contains "Program1,Program2,Program3.." like so on. I should able to read this string and filter the data for those program related data. As i get the list of values in the form of string i need to store this as a list or column and then only can filter. 

@Surekha 

I don't fully understand but you may create a table using the following DAX

List =
VAR String = "P1,P2,P3" -- place your sting here
VAR Items =
SUBSTITUTE ( String, ",", "|" )
VAR Length =
COALESCE ( PATHLENGTH ( Items ), 1 )
VAR T1 =
GENERATESERIES ( 1, Length, 1 )
RETURN
SELECTCOLUMNS ( T1, "Project", PATHITEM ( Items, [Value] ) )

CE2AC366-65A2-45A0-957F-CF23962C9A76.jpeg

Hi Tamerj,

i have created a measure same as mentioned.  I assume that it returns the table but somehow i am not able to see any thing. Do i need to create any table prior to this?

RLS_Key =
VAR String = "P1,P2,P3" -- place your sting here
VAR Items =SUBSTITUTE ( String, ",", "|" )
VAR Length =COALESCE ( PATHLENGTH ( Items ), 1 )
VAR T1 =GENERATESERIES ( 1, Length, 1 )
RETURN
SELECTCOLUMNS (T1,"Project",PATHITEM(Items,[Value]))
 
Could you please clarify.

 

@Surekha 
Again, I'm sorry but I really don't understand what is this string or what are you trying to achieve. However, the proposed DAX is for a calculated table as per your request not a for measure.

Thanks for your reply. As suggested instead of using as measure used the same in the Manager role. It is working as expected. parent_code-RLS.png

amitchandak
Super User
Super User

@Surekha , Option one remove double quotes and split commas into new rows

https://www.tutorialgateway.org/how-to-split-columns-in-power-bi/

 

also check this option

Power BI- Text Part slicer to filter/search text - https://youtu.be/MKKWeOqFG4c

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

HI Amit, Thanks for your response. Is there a way i can insert a measure value in a new table. After that i can do the transformation the way you shared the details.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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