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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
dsp9911
Regular Visitor

Creating Measure for a table without using USERELATIONSHIP()

Hi 

I have 2 tables one is geography table(dimension table) and another one is a fact table.In the fact table the seller gets order from all over the world and so there are 2 columns where ordered country show from which country the order is placed and warehouse country shows from which country the order will be shipped.

I have to count how many orders were placed from a country for business requirements and also which country is handling the most number of orders.I have created a active and an inactive relationship between the 2 tables.

1. geography(country) ---> fact(ordered country) 

2.geography(country) ---> fact(warehouse country)

dsp9911_0-1665594285983.png

I have created a measure in fact table to count which country is handling most number of orders.

count of warehouse country = CALCULATE(COUNT(List[Warehouse Country]),USERELATIONSHIP(geography[country],LIST[warehouse country]))

So this gives me data for each country like which country handles how much orders and this works fine.

But when i apply RLS on Country  from  geography table it gives a error where I cant use the USERELATIONSHIP() with RLS.

I need both the relationship in my model for calculations.

 

 

So is there any workaround for this?(also i cant create a duplicate geography table to have seperate relationship on different data due to size restrictions)

@Anonymous @Sus @PaulDBrown @Greg_Deckler 

7 REPLIES 7
mariussve1
Super User
Super User

Hi,

 

Does this help you?

https://community.powerbi.com/t5/Desktop/USERELATIONSHIP-and-RLS/m-p/787463

Br

Marius


Br
Marius
BI Fabrikken
www.bifabrikken.no
PaulDBrown
Community Champion
Community Champion

I've tested this and I think all you need is a simple COUNT measure...

Count Warehouse = 
COUNT('List Table'[Warehouse Country])

2022-10-14.pngcount.gif





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






It doesnt work when RLS is applied on Gcountry column the visualisation using measure count warehouse breaks and doesn't show data

PaulDBrown
Community Champion
Community Champion

Not sure if RLS allows the use of TREATAS, but you can try:

Warehouse count =
CALCULATE (
    [Count warehouse Country],
    ALL ( 'Geagraphy Table' ),
    TREATAS (
        VALUES ( 'Geagraphy Table'[Country] ),
        'List Table'[Warehouse Country]
    )
)




Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






I used TREATAS but that leads to loss of some data i.e if value for a seller should be 500 after using TREATAS it gives only 430 

Any chance you can share some sample data?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Sorry but can't share the data.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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