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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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