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
Haleem
Helper III
Helper III

Dynamic RLS with UserName() and Multiple Cost Centers and Cost Centers Nodes in hierarchy

My sample files are here
https://1drv.ms/f/s!AtMKO3vGEsG5gSQODCatb86kNR48


In continuation of my previous post which was resolved 
Dynamic RLS with UserName() and Multiple Cost Centers and Cost Centers Nodes in hierarchy 

 

Now I would like to ruplicate SAP BW Access file to Power BI. Access File is today managed in Excel and being uploaded to BW in order to control access rights of our SAP BI Cost Reports.

 

I would like to use the same file and upload it to Power BI in order to manage the access rights of users automatically using the USERNAME() in Power BI cost reports, to avoid maintaining parellel two access files. 

 

Problems:

None of the below table contains UNIQUE field!!!!!!

 

1. Access file contains combination of USER, Cost Center and/or Nodes

2. Data tables contains only Cost Center column not nodes

3. But we have separate file which contains Cost Centers Per node.. so how to replaces nodes in Access file (in point 1) with the cost centers 

4. how to link Access file to the Data File and then apply USERNAME function on access file in order to limit the user to see cost center he/she is having access to. 

 

 

What I ideally want: 

1. Upload all the three files to Power BI

2. Replace Nodes in Access File with relevant Cost Centers and link Access file to the Data file

3. Use USERNAME function through RLS Roles in order to manage the access rights automatically. 

 

Below is the overview of each of Sample tables. 

 

1. Data Table

Data table.png

 

 

2. Access File

 

Access File.png

 

3. Nodes and Cost Centers

Nodes vs. Cost Centers.png

3 ACCEPTED SOLUTIONS
v-frfei-msft
Community Support
Community Support

Hi @Haleem,

 

We can merge Nodes and Cost centers and Access file1 tables to get the result table as you want. 

 

Capture.PNG2.PNG

 

Please refer to the M code in Power query.

 

let
    Source = Table.NestedJoin(#"Nodes and Cost centers",{"Nodes "},#"Access file1",{"CCtr Broadcast"},"Access file1",JoinKind.FullOuter),
    #"Expanded Access file1" = Table.ExpandTableColumn(Source, "Access file1", {"User Name", "CCtr Broadcast"}, {"Access file1.User Name", "Access file1.CCtr Broadcast"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Access file1", "Custom", each if[Cost Center] = null then [Access file1.CCtr Broadcast] else [Cost Center]),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Access file1.CCtr Broadcast", "Nodes ", "Cost Center"})
in
    #"Removed Columns"

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

Thanks a lot. I have implemented the solution on REAL data and It worked well Except one problem. The Merged Table is missing some USERS and showing null value for the users who do exists in the Access file, as you can see in the below screenshot. It's not the case for all users, but there are many users that they do not not appear in the Merged table.

 

2019-02-11 17_54_33-Cost Centers and Nodes - Power Query Editor.png

View solution in original post

Hi Frank,

 

It was my mistake, I didn't use "Full outer" option  while merging tables, now I did. It's working very fine now and the issues I observed in first test is resolved now. I will do further testing.

 

But Thanks a lot, It is a great help for me 🙂

View solution in original post

4 REPLIES 4
v-frfei-msft
Community Support
Community Support

Hi @Haleem,

 

We can merge Nodes and Cost centers and Access file1 tables to get the result table as you want. 

 

Capture.PNG2.PNG

 

Please refer to the M code in Power query.

 

let
    Source = Table.NestedJoin(#"Nodes and Cost centers",{"Nodes "},#"Access file1",{"CCtr Broadcast"},"Access file1",JoinKind.FullOuter),
    #"Expanded Access file1" = Table.ExpandTableColumn(Source, "Access file1", {"User Name", "CCtr Broadcast"}, {"Access file1.User Name", "Access file1.CCtr Broadcast"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Access file1", "Custom", each if[Cost Center] = null then [Access file1.CCtr Broadcast] else [Cost Center]),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Access file1.CCtr Broadcast", "Nodes ", "Cost Center"})
in
    #"Removed Columns"

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Thanks a lot. I have implemented the solution on REAL data and It worked well Except one problem. The Merged Table is missing some USERS and showing null value for the users who do exists in the Access file, as you can see in the below screenshot. It's not the case for all users, but there are many users that they do not not appear in the Merged table.

 

2019-02-11 17_54_33-Cost Centers and Nodes - Power Query Editor.png

Hi @Haleem,

 

How did you merge the tables? Did you use the full outer option?

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi Frank,

 

It was my mistake, I didn't use "Full outer" option  while merging tables, now I did. It's working very fine now and the issues I observed in first test is resolved now. I will do further testing.

 

But Thanks a lot, It is a great help for me 🙂

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.