Forum Discussion
Embedded RLS
- 3 years ago
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] ) )
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 |
If you place USERNAME ( ) in a card visual, what do you see?
- dinesh1233 years ago
Helper II
Sorry if we pass Username= "p1,p2,p3:c1,c2,c3.... (In Java SDK) Can we read it in embedded Rls as two fields?
- tamerj13 years ago
Community Champion
I thought you've already done that. I've never tried 😅
- dinesh1233 years ago
Helper II
Hi tamerj1, daXtreme, JihwanKim
I'm trying to pass Username as "P1,P2,P3,..:C1,C2,C3,..." in embedded RLS(by Java SDK) from two different slicers. Were P and C are two different fields.
Whenever I try with above sicenario i'm able to pass only P values, but I need to pass P and C values individually.
I'm giving this code in Manage roles in RLS in Powerbi. Where P is for Program code and C is for Childcode.
[parent_org_cd] IN {
Var input1 = Username()
VAR indexOfSeparator = FIND ( ":", input1, 1, BLANK () )
VAR String = LEFT ( input1, LEN ( input1 ) - indexOfSeparator )
VAR Items =
SUBSTITUTE ( String, ",", "|" )
VAR Length =
COALESCE ( PATHLENGTH ( Items ), 1 )
VAR T1 =
GENERATESERIES ( 1, Length, 1 )
RETURN
SELECTCOLUMNS ( T1, "Project", PATHITEM ( Items, [Value] ) )}
&& [child_org_cd] IN{
Var input2 = Username()
VAR indexOfSeparator1 = FIND ( ":", input2, 1, BLANK () )
VAR String1 = Right ( input2, LEN ( input2 ) - indexOfSeparator1 )
VAR Items1 =
SUBSTITUTE ( String1, ",", "|" )
VAR Length1 =
COALESCE ( PATHLENGTH ( Items1 ), 1 )
VAR T2 =
GENERATESERIES ( 1, Length1, 1 )
RETURN
SELECTCOLUMNS ( T2, "Project1", PATHITEM ( Items1, [Value] ) )}
- dinesh1233 years ago
Helper II
For one field (program code) your code work fine. Now I need to read program and child, here we are using two slicers one for program and other for child.
- dinesh1233 years ago
Helper II
P1,P2,P3,... If I place username() in card. I passed only for program code in SDK. Not tested for childcode