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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
id013
Helper V
Helper V

Anyone having issues using USERELATIONSHIP and filters?

So I have a table that shows product sales. There is a purchase date and a return date as well as a field that states whethere they are within 30 days of purchase date, there is also a "Within 30 Days" slicer that I can use to filter the data by that field. So I have 2 relationships between my sales table and the date dimension:

purchase_date_key = date_key

return_date_key = date_key

 

The primary relationship is purchase date 

 

So I have 2 measures:

count_purchases := CALCULATE(DISTINCTCOUNT(order_id),ISBLANK(purchase_date)=FALSE())

count_returns := CALCULATE(DISTINCTCOUNT(order_id),ISBLANK(purchase_date)=FALSE(),ISBLANK(return_date)=FALSE(),USERELATIONSHIP(return_date_key,date_key)

 

Both seem to work fine but when I want to count the number of returns within 30 days of purchase the filter doesn't seem to work properly.

 

If I do:

CALCULATE(DISTINCTCOUNT(order_id),ISBLANK(purchase_date)=FALSE(),ISBLANK(return_date)=FALSE(),USERELATIONSHIP(return_date_key,date_key,FILTER(sale,within_30_days=TRUE)) it returns blank (it shouldn't)

 

If I do:

CALCULATE(DISTINCTCOUNT(order_id),ISBLANK(purchase_date)=FALSE(),ISBLANK(return_date)=FALSE(),within_30_days=TRUE,USERELATIONSHIP(return_date_key,date_key) it returns the right count but when I set the within_30_days slicer to FALSE the count doesn't decrease. 

 

Is there another way I can accomplish this? 

 

 

4 REPLIES 4
Anonymous
Not applicable

Hi @id013 ,

 

It's hard to find the solution only by these formulas. Can you show some sample data to us if you don't have any Confidential Information?

 

Best Regards,

Jay

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

Not sure I got it but if you want to move one the day +/- 30 days try like

-30 = CALCULATE(SUM(purchase[Amount]),dateadd('Date'[Date],-30,day),userelation(..))

+30 = CALCULATE(SUM(purchase[Amount]),dateadd('Date'[Date],30,day),userelation(..))

 

If you want to use some kind clause with both dates, refer :https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Appreciate your Kudos.

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

hi @amitchandak 

Unfortunately I don't have control over the fields and the within_30_days field is actually just a True\False value that gets updated. 

 

 

 

What exactly you want to do with that 30 day filter. Can you explain with example

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.