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
abhiram342
Employee
Employee

Help on RLS in Power BI

Hi Team - We have tabular model (screenshot below) and enabled RLS on the "DimSubsidiary" table, which is applying security filter to the "FactSales" tables.

However, we have a requirement to show sales different when slicer is placed on Geography.

Example:

As per Sample Data below, User A is allowed to see US and UK Subsidiary Data

For User A: 

Total Sales  (Subsidiary=US) = 100 + 600 ( Row 1 + Row 2) . This is working as expected.

Total Sales (For Geo=US) = 100 ( because of RLS user A can see Row 1 and Row 2) and For US, it's 100.

but User A has access to US subsidary , they should be able to see Revenue for US Geography i.e they should see sales  as 

( 100 (Row1) + 500 (Row 3) + 700 (Row 5) Beacuse of RLS in place this will not work

Can you please suggest how to proceed further in order to show 1300 as sales for User A when we select Geo="US" ? 

Do I need to create any bridge table based of Fact? 

 

SampleData.jpg

Data Model

Data Models.jpg

 

Thanks,

Abhiram

 

 

2 REPLIES 2
Mrxiang
Helper II
Helper II

Based on your requirement, it seems like you need to create a bridge table to connect the "DimSubsidiary" table and the "DimGeography" table. This bridge table will have a row for each combination of subsidiary and geography that a user has access to.

For example, if User A has access to US and UK subsidiaries and US and Canada geographies, the bridge table would have the following rows:

Subsidiary	Geography
US	US
UK	US
US	Canada
Then, you can create a measure in the "FactSales" table that sums up the sales for each combination of subsidiary and geography in the bridge table. The measure formula would look something like this:

Total Sales = 
CALCULATE(
    SUM(FactSales[Sales]),
    USERELATIONSHIP(BridgeTable[Subsidiary], DimSubsidiary[Subsidiary]),
    USERELATIONSHIP(BridgeTable[Geography], DimGeography[Geography])
)
This measure will take into account the RLS filter on the "DimSubsidiary" table and only show sales for the subsidiaries that the user has access to. It will also show sales for the geographies that the user has access to, based on the bridge table.

When the user selects "US" in the geography slicer, the measure will show the total sales for all subsidiaries that the user has access to in the US geography.

I hope this helps! Let me know if you have any further questions.

Hi @Mrxiang  - thank you for your respone. I have implemented your suggestions but it's not working i.e For User A TotalSales For US coming as 600 (TotalSales Measure) due to RLS but it should show 1300. Please let me know if I'm missing something.

 

Measure:

Total Sales =
CALCULATE(
    SUM('Fact Sales'[SalesAmount]),
    USERELATIONSHIP('BridgeSubGeo'[SubsidiaryID], DimSubsidiary[SubsidiaryID]),
    USERELATIONSHIP(BridgeSubGeo[GeoID], DimGeography[GeoID])
)
RLS Code ON DimSubsidiaryTable:
VAR SUBSIDIARIES =
CALCULATETABLE (
VALUES ( 'Dim User Security'[SubsidiaryID] ),
'Dim User Security'[UserAlias] = USERPRINCIPALNAME ()
)
RETURN
'DimSubsidiary'[SubsidiaryID] IN SUBSIDIARIES
ModeL after adding bridge Table:
modelss.jpg

Acutal Data:

actual data.jpg

After RLS:

RLSS.jpg

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.

Top Solution Authors