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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ClaudeV
Regular Visitor

RLS and Calculate

Hi guys,

 

I need some help with RLS and Calculate.

 

My data is setup as the following:

Each Location connected to a email address and each location within a Province

 

I have created a RLS for each Location using the email address and the USERPRINCIPALNAME() function.  But when I view as the user I cannot get the total revenue for the region to be displayed.  I then created a separate table for the revenue per region.  Everything is working as it should.  What I would like to do is insert a namecard with dynamic content to display ONLY the region total based on the user login.

 

What I currently have is the following:

RLS Province = CALCULATE(SUM('Sum of Totals'[Net Sales]),'Sum of Totals'[Province]="PROVINCE NAME",'Sum of Totals'[Company]="Franchise")
 
I have 17 Provinces and I do not want to create one for each Province
 
Ideally what I would like to do is make the bold underlined part of the formula dynamic to only display the sum of net sales for the province based on the user login (as per RLS)
RLS Province = CALCULATE(SUM('Sum of Totals'[Net Sales]),'Sum of Totals'[Province]="PROVINCE NAME",'Sum of Totals'[Company]="Franchise")
 
I want to filter between Companies ('Sum of Totals'[Company]="Franchise") as well, hence the CALCULATE measure
 
I want the Location Net Sales to be displayed in the three namecards (PREVIOUS-, CURRENT-, NEXT MONTH) and the SUM of net sales for the PROVINCE to be displayed in the RLS Province and OTHER Province - based on the user login (RLS)
ClaudeV_1-1652793381343.png

 

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@ClaudeV,

 

Here are two solutions you can try. Each solution uses the following measure and RLS filter for DimLocation:

 

Province Net Sales = SUM ( 'Sum of Totals'[Net Sales] )

 

DataInsights_0-1652820579843.png

 

Solution 1

 

Create a many-to-many relationship between DimLocation and Sum of Totals. DimLocation should filter Sum of Totals.

 

DataInsights_1-1652820627721.png

 

Solution 2

 

There is no relationship between DimLocation and Sum of Totals. Add an RLS filter to Sum of Totals:

 

DataInsights_2-1652820910336.png

 

[Province] IN
CALCULATETABLE (
  VALUES ( DimLocation[Province] ),
  DimLocation[Email] = USERPRINCIPALNAME()
)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ClaudeV
Regular Visitor

@DataInsights thank you.  Solution 2 worked.  I had to use solution 2 as I created relationships between the locations and that mad a mess of everything

@ClaudeV, glad to hear that!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




DataInsights
Super User
Super User

@ClaudeV,

 

Here are two solutions you can try. Each solution uses the following measure and RLS filter for DimLocation:

 

Province Net Sales = SUM ( 'Sum of Totals'[Net Sales] )

 

DataInsights_0-1652820579843.png

 

Solution 1

 

Create a many-to-many relationship between DimLocation and Sum of Totals. DimLocation should filter Sum of Totals.

 

DataInsights_1-1652820627721.png

 

Solution 2

 

There is no relationship between DimLocation and Sum of Totals. Add an RLS filter to Sum of Totals:

 

DataInsights_2-1652820910336.png

 

[Province] IN
CALCULATETABLE (
  VALUES ( DimLocation[Province] ),
  DimLocation[Email] = USERPRINCIPALNAME()
)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.