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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Many to many relationship date filtering

Edit: Made post more readable, sample pbix file:

https://wetransfer.com/downloads/47f25500d60a96f3fd42a48335ce3c1220181218093545/c75f94

 

 

Hi,

 

I cant seem to figure out how to do row by row filtering between dates on a many to many relationship setup and any help would be greatly appreciated. I currently have a many to many relationship setup (see the image below).

 

example.png

 

The emails table has email campaign information. Some fields here are "EmailName", "AccountID" and the "SendDate" of each email (one email is send to multiple AccountID's, more importantly the same "EmailName" is being send at differing "SendDate" 's).

 

The order table contains order information from consumers. Some fields here are "AccountID", "Ordernumber" and "OrderDate". One account can have many orders that all have different order dates.

 

Now what I want to do is the following: For each email send, I want to see which people made orders with an "OrderDate" after the "SendDate" and count them, so that per email I have a total amount of orders following the email send. I have tried this with a measure using calculate a OrderDate>Max(SendDate) filter() but this does then not take into account that the same email is being send at different times, furthermore PowerBI ran into memory issues with these large tables and using measures in measures. Again, any help is greatly appreciated!

 

 

Example of desired output table:

 

EmailName, Orders_Within_1_week

Email 1, 0
Email 2, 2
Email 3, 2

 

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

HI, @Anonymous

After my test on your pbix file, you could try this way as below:

Step1:

Add a new AccountID for Orders table

new AccountID = Orders[AccountID]

Step2:

Use this formula to create a Orders_Within_1_week measure

Orders_Within_1_week = var _table1=SUMMARIZE(Emails,Emails[AccountID],Emails[EmainName],Emails[SendDate]) 
var _table2=SUMMARIZE(Orders,Orders[new AccountID],Orders[OrderNumber],Orders[OrderDate]) 
var _table3=FILTER(GENERATE(_table1,_table2),AND([AccountID]=[new AccountID],DATEDIFF([SendDate],[OrderDate],DAY)>=0&&DATEDIFF([SendDate],[OrderDate],DAY)<=7)) return
CALCULATE(COUNTAX(_table3,[OrderNumber]))+0

Result:

10.JPG

 

Best Regards,

Lin

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

View solution in original post

5 REPLIES 5
v-lili6-msft
Community Support
Community Support

hi, @Anonymous

 

Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-lili6-msft this indeed works and my apologies for getting back to you so late, however with the large dataset im working with this turns out to be too slow to work with, hence I eventually just did the joins in my SQL queries. Thank you for your time!

v-lili6-msft
Community Support
Community Support

HI, @Anonymous

After my test on your pbix file, you could try this way as below:

Step1:

Add a new AccountID for Orders table

new AccountID = Orders[AccountID]

Step2:

Use this formula to create a Orders_Within_1_week measure

Orders_Within_1_week = var _table1=SUMMARIZE(Emails,Emails[AccountID],Emails[EmainName],Emails[SendDate]) 
var _table2=SUMMARIZE(Orders,Orders[new AccountID],Orders[OrderNumber],Orders[OrderDate]) 
var _table3=FILTER(GENERATE(_table1,_table2),AND([AccountID]=[new AccountID],DATEDIFF([SendDate],[OrderDate],DAY)>=0&&DATEDIFF([SendDate],[OrderDate],DAY)<=7)) return
CALCULATE(COUNTAX(_table3,[OrderNumber]))+0

Result:

10.JPG

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lili6-msft
Community Support
Community Support

HI, @Anonymous

Could you please share a simple sample pbix file or some data sample and expected output. Do mask sensitive data before uploading.

 

 

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi,

 

Here is the link to an example pbix file:

https://wetransfer.com/downloads/47f25500d60a96f3fd42a48335ce3c1220181218093545/c75f94

 

The output should be the following table:

 

EmailName, Orders_Within_1_week

Email 1, 0
Email 2, 2
Email 3, 2

 

Thanks!

 

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors