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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
davi_luc
Regular Visitor

Date column filter another table

Hello.

I'm having troubles filtering a table based on the selection of another table, so I would be able to calculate some measures.

My main table has two columns, ID and Date Order, wich are non unique. My secondary table has the same two columns, also with non unique values.

I would like to filter on the second table, for a given ID and Date Order, all the rows for that ID and wich the day diference betwen the Table A[Date Order] and Table B[Date Order] <= 5 and >= 0. 

To illustrate

davi_luc_1-1672695221938.png

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@davi_luc , we can copy the date from table to table to and take a diff and then use as diff

 

a new measure

Countx(Table2 ,

var _col = maxx(filter(Table1, Table1[ID] = Table2[ID]), Table1[Date])

var _diff = abs(datediff(Table2[Date], Table1[Date], Day) )

return

if(_diff <=5, Table2[ID], blank())

 

 

in case you want create a column

new column =

var _col =maxx(filter(Table1, Table1[ID] = Table2[ID]), Table1[Date])

return  abs(datediff(Table2[Date], Table1[Date], Day) )

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

Hello @amitchandak , thanks for your response.
If I understood correctly, your answer won't work for me.
In the example, if we look at Table A, ID = 1, we have two different dates, 15/01/2022 and 10/01/2022. The "allowed" dates, for ID = 1, in Table B, should be 5,6,7,8,9,10,11,12,13,14,15 of january.

Your solution, since it uses a MAXX, would only allow the dates 10,11,12,13,14,15 of january.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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