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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
filipbobczuk
Frequent Visitor

USERELATIONSHIP in a measure

I have two tables: 'Deals' and 'Dates' with couple many to one inactive relationships (for example based on 'Deals'[Created Date] and 'Deals'[Won Date]).
I ran two queries in Power BI Desktop using DAX Query View:
1.

 

EVALUATE
	{
		CALCULATE(
			COUNT( 'Deals'[Deal ID] ),
			USERELATIONSHIP( 'Dates'[Date], 'Deals'[Won Date] ),
			FILTER(
				'Deals',
            	'Deals'[Product] = "XYZ" &&
				NOT ISBLANK('Deals'[Won Date])
			)
		)
	}

 

2. 

 

EVALUATE
	{
		CALCULATE(
			COUNT( 'Deals'[Deal ID] ),
			FILTER(
				'Deals',
            	'Deals'[Product] = "XYZ" &&
				NOT ISBLANK('Deals'[Won Date])
			)
		)
	}

 

I am getting two different results, which makes me wondering why if there are no outer filters applied and how does calculate work in the bacground to obtain different outputs here.
I have went through different 'How does CALCULATE work' articles but could not find one that covers my case.
Thank you in advance!

3 REPLIES 3
talespin
Solution Sage
Solution Sage

hi @filipbobczuk 

 

Can you please share sample data with which you are seeing the count difference.

filipbobczuk
Frequent Visitor

Hey @Chakravarthy,
thank you for your reply, do you know (what Im most interested in) where is the difference in the output in my two queries coming from and why is it happening?

Chakravarthy
Resolver II
Resolver II

Hi @filipbobczuk  -

Please try below code:

SOLUTION 1:
===========
When there is Inactive Relationship
 
EVALUATE
{
CALCULATE(
COUNT( 'Deals'[Deal ID] ),
USERELATIONSHIP( 'Dates'[Date], 'Deals'[Won Date] ),
REMOVEFILTERS('Deals')
KEEPFILTERS(
            'Deals'[Product] = "XYZ" &&
NOT ISBLANK('Deals'[Won Date])
)
)
}
SOLUTION 2:
==================
Remove the Inactive Relationship and use below code
 
EVALUATE
{
CALCULATE(
COUNT( 'Deals'[Deal ID] ),
TREATAS( VALUES('Dates'[Date]), 'Deals'[Won Date] ),
FILTER('Deals',
            'Deals'[Product] = "XYZ" &&
NOT ISBLANK('Deals'[Won Date])
)
)
}

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.