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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Jazzed2b
New Member

Filtering data between two columns from different tables

I have two tables with a ONE to MANY relationship via POLICY NUMBER.  On the ONE table I have a column POLICY EFFECTIVE DATES and on the MANY table I have multiple drivers identified on a DELETEDATE.  I want to filter to count only the number of drivers where the difference betwen POLICY EFFECTIVE DATES and DELETEDATE are less than 365.  The reason being that when a policy expires after one year (365) they are all marked with a DELETEDATE 365 days after the POLICY EFFECTIVE DATE.  I only want to cound the number of drivers which are deleted before the policy expires at 365. 

 

Here is a sample of the table relationships.  I have tried filtering the data based on the relationships, but I do not know if Power BI can subtract the DELETEDATE from the POLICY EFFECTIVE DATE as a condition prior to filter and summing the remaining driver.  Is this something better accomplished as a query on Access DB and then loading the data in Power BI or is there a formula in Power BI to compare the dates on these two columns and then summing the drivers which qualify (meaning having a DELETEDATE less than 365 days from the POLICY EFFECTIVE DATE)? Screenshot 2024-06-13 185732.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Jazzed2b ,

 

You can try it by following steps:

1.you can create a calculated column to compute the difference in days

DaysDifference = DATEDIFF(RELATED(AL Policy Data[EFFECTIVE DATE]), Driver Report[DELETEDATE], DAY)

2.you can easily filter this table to include only the rows where is less than 365 and then count the number of drivers. This can be done by creating a measure

DriversCount = COUNTROWS(FILTER(Driver Report,Driver Report[DaysDifference] < 365))

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Jazzed2b ,

 

You can try it by following steps:

1.you can create a calculated column to compute the difference in days

DaysDifference = DATEDIFF(RELATED(AL Policy Data[EFFECTIVE DATE]), Driver Report[DELETEDATE], DAY)

2.you can easily filter this table to include only the rows where is less than 365 and then count the number of drivers. This can be done by creating a measure

DriversCount = COUNTROWS(FILTER(Driver Report,Driver Report[DaysDifference] < 365))

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

@Jazzed2b , as they have on to many relation

 

a new column in diver report table

 

=  datediff(related('AL Policy Data'[Effective Date]), 'Diver Data'[deleted date], date)

 

 

refer 4 ways (related, relatedtable, lookupvalue, sumx/minx/maxx with filter) to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

 

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.