Forum Discussion
Embedded RLS
tamerj1
Hi all,
We are using Embedding 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 embedded 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.
For Example:
{
"accessLevel": "View",
"datasetId": "cfafbeb1-*****-a46fb27ff229",
"identities": [
{
"username": "Program1",
"roles": [
"sales"
],
"datasets": [
"cfafbeb1-******-a46fb27ff229"
]
}
]
}
Here we are passing one Program from Java SDK. We were able to apply RLS for one value. However,
{
"accessLevel": "Create",
"datasetId": "cfafbeb1-8******e-a46fb27ff229",
"identities": [
{
"username": "Program1,Program2,Program3,….",
"roles": [
"sales"
],
"datasets": [
"cfafbeb1-80*****e-a46fb27ff229"
]
}
]
}
But we want to pass more programs from username but we are getting output as single string not as individual Programs.
Here we need to pass multiple values from Username and read it as individual Programs as values in Embedded PowerBI not as single string.
For reference: https://learn.microsoft.com/en-us/power-bi/developer/embedded/cloud-rls
Hi dinesh123
Please try[Program] IN VAR String = USERNAME ( ) VAR Items = SUBSTITUTE ( String, ",", "|" ) VAR Length = COALESCE ( PATHLENGTH ( Items ), 1 ) VAR T1 = GENERATESERIES ( 1, Length, 1 ) RETURN SELECTCOLUMNS ( T1, "Project", PATHITEM ( Items, [Value] ) )dinesh123
Please try= [Child_code] IN VAR Input = USERNAME () VAR Length = LEN ( Input ) VAR IndexSep = COALESCE ( FIND ( ":", Input, 1, BLANK () ), Length ) VAR String = IFERROR ( RIGHT ( Input, Length - IndexSep ), BLANK () ) VAR String2 = COALESCE ( String, CONCATENATEX ( VALUES ( ChildOrg[Child_code] ), ChildOrg[Child_code], "," ) ) VAR Items = SUBSTITUTE ( String2, ",", "|" ) VAR Length = COALESCE ( PATHLENGTH ( Items ), 1 ) VAR T1 = GENERATESERIES ( 1, Length, 1 ) RETURN SELECTCOLUMNS ( T1, "Project", PATHITEM ( Items, [Value] ) )
31 Replies
- dinesh123
Helper II
For Example:
{
"accessLevel": "View",
"datasetId": "cfafbeb1-*****-a46fb27ff229",
"identities": [
{
"username": "Program code = P1,P2,P3,….":“Child code= C1,C2,C3”
"roles": [
"sales"
],
"datasets": [
"cfafbeb1-******-a46fb27ff229"
]
}
]
}
Here we are passing Program code and Child code from Java SDK, now with your help we are able to pass the multiple program codes, However, can we pass Child code also corresponding to that Program code?
As we are using Program code and child code as two different slicers
Ex:Program code
Child Code
P1
C1
P1
C2,C3
P1
C4
P2
C5,C6
P2
C7