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! Learn more

Reply
Anonymous
Not applicable

Filter fact table by two date dimensions at the same time (using USERELATIONSHIP)

Hi, I have an Orders fact table that has an order date and a shipped date keys that are related to the same Date dimension table. 

The order date is the active relationship and the shipped date is inactive. 

I can get a count of orders by order date using:

 

Order Count = COUNTROWS(Orders)

 


And a count by shipped date using:

 

Shipped Order Count = CALCULATE([Order Count], USERELATIONSHIP(Order[ShipedDateKey], 'Date'[DateKey])

 

 

But how can I show orders that were placed and shipped in the same period? How can I use both relationships at the same time?

 

Another important point is that DateKey and ShippedDateKey are real keys and not dates. So I can't filter based on those columns directly. 


Thank you for your help!

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Ideally the relationship should be between proper date columns.  Also, what do you mean by "show orders that were placed and shipped in the same period"?  Share some data, define same period and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@Anonymous ,

Try a measure like

placed and shipped in the same period =
var _min = maxx(allselected(date),date[date])
var _max = maxx(allselected(date),date[date])
return
calculate([ Order Count ], filter(Order, Order[ShipedDateKey]<=_max && Order[ShipedDateKey]>-_min))

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
Anonymous
Not applicable

Thank you. Unfortnately, my date keys are actual keys and not date values. Is there a way to use USERELATIONSHIP inside a filter statement?

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.

Top Solution Authors