Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
I have data model with 4 tables (I don't have much freedom to make changes to it)
Order Fact, Buyer Dim, Caller Dim and People Dim. Sometimes the buyer and the caller can be the same person and sometime they are different people. Now I am using USERELATIONSHIP to get a count of orders and putting it in a grid visual to show all the records. The whole point of USERELATIONSHIP is to get the location to respond to both buyers and callers (to show the actual number of orders tied to a location regardless of who (buyer or caller) is tied to that order. This works out perfect in the grid visual but goes horribly wrong in other visuals) Not elegant, but works. My question is how do I get it to count all the rows where the buyer is not the same as the caller or the instances where they're the same.
inactiverelationshipmeasure = CALCULATE('Order Fact'[Total Orders],USERELATIONSHIP(BuyerDim[BuyerID],'PeopleDim'[Id]))Total Orders = COUNT('Order Fact'[Order ID])
In the above visual the total row count should be 7. How do I go about achieving that? I've tried keepfilters to no avail. I want to count all the rows using userelationship measure where BuyerID = CallerID or BuyerID <> CallerID. Thank you in advance for taking your time to read this post. I created two columns, then tried to pass these columns as filters into my userelationship measure, but it didn't work. I am on direct query mode in ssas and operators such as IN don't work for me 😞
Caller different Buyer = IF('Order Fact'[CallerID]<>'Order Fact'[BuyerID],1,0)Caller same Buyer = IF('Order Fact'[CallerID]='Order Fact'[BuyerID],1,0)Total Orders NEW(Wrong-gives me a blanks) = CALCULATE(COUNTROWS('Order Fact'),
USERELATIONSHIP(BuyerDim[BuyerID],PeopleDim[Id]),
KEEPFILTERS('Order Fact'[Caller same Buyer]=1),
KEEPFILTERS('Order Fact'[Caller different Buyer]=1)
)
Link to sample file: https://www.dropbox.com/s/rte1zs13csx4ghz/example2.pbix?dl=0
Solved! Go to Solution.
Hi @chat_peters ,
Is what you want something like this?
Measure =
COUNT ( 'Order Fact'[Order ID] )
+ CALCULATE (
COUNT ( 'Order Fact'[Order ID] ),
USERELATIONSHIP ( 'PeopleDim'[Id], BuyerDim[BuyerID] ),
'Order Fact'[Caller different Buyer] = 1
)
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This solution works great. I am going with @Icey's solution for now because it works with all the other filters and in the direct query mode and the outdated version of power bi I am working with. I made tiny tweak to the formula
Measure =
CALCULATE(COUNT( 'Order Fact'[Order ID] ), 'Order Fact'[Caller Buyer Same] =1)
+ CALCULATE (
COUNT ( 'Order Fact'[Order ID] ),
USERELATIONSHIP ( 'PeopleDim'[Id], BuyerDim[BuyerID] ),
'Order Fact'[Caller different Buyer] = 1
)Thank you @Icey so much😊
Hi @chat_peters ,
Is what you want something like this?
Measure =
COUNT ( 'Order Fact'[Order ID] )
+ CALCULATE (
COUNT ( 'Order Fact'[Order ID] ),
USERELATIONSHIP ( 'PeopleDim'[Id], BuyerDim[BuyerID] ),
'Order Fact'[Caller different Buyer] = 1
)
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I made this measure but it's not working, it's only taking into consideration when the buyer is the same as caller.
Total Orders with filter_2 = CALCULATE(
COUNT('Order Fact'[Order ID]),
USERELATIONSHIP(BuyerDim[BuyerID],PeopleDim[Id]),
FILTER(
'Order Fact',
OR(
'Order Fact'[Caller different Buyer]=1,
'Order Fact'[Caller same Buyer]=1
)))
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.