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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
SeanGannon
New Member

Comparing dates between two unrelated fact tables (many to many)

We have two fact tables - Payments and Customer Contacts.  We would like to find out how many Payments are made within 6 days of a Customer Contact (a call or email from a collections staff member).  Payments and Customer Contacts both relate to DimAccount, and both will have many records for each account.

 

FactPayments

DimAccountID

PaymentDate

PaymentAmount

 

FactCustomerContact

DimAccountID

DimCampaignID

ContactDate

 

This measure uses TREATAS to force this relationship, this allows be to display both dates together in a table.  

Payment = CALCULATE(SUMX(Payments, Payments[Payment Amount]),TREATAS(VALUES('Customer Contacts'[DimCustomerID]),Payments[DimCustomerID]))
 
SeanGannon_0-1669774999326.png

 

But I can't seem to figure out how to filter this measure to only show Payments where the DATEDIFF between these dates is between 0 and 6.

 

Thanks!

 
3 REPLIES 3
Anonymous
Not applicable

Hi @SeanGannon ,

 

Can you share some sample data?

 

 

amitchandak
Super User
Super User

@SeanGannon , one the way is to get the contract date in Fact payment

 

a new column

Con date= maxx(filter(Contract, Contract[DimAccountID] = payment[DimAccountID] && contract[ContactDate]< Payment[Payment Date]), Payment[Payment Date])

 

 

now you can only work with payment fact

 

countx(filter(payment, payment[Payment Date]<= [con date] +6 && payment[Payment Date]>= [con date] ), [DimAccountID])

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

There are (potentially) many contacts per payment, won't this force repeating records into FactPayment?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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