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
JL0101
Helper II
Helper II

How do I compare 1 date with several dates in 2 tables to find the minimum

 

The goal is to categories table 1 with the the dates of table 2 by whichever date is closer in table 2. How can this be achieved in power query? I have provided the Dax script below.

 

Table 1: model with version

Model Version Number

 
 
EI117/01/2023
EI119/01/2023
EI128/01/2023
EI102/02/2023
EI205/02/2023
EI226/02/2023
EI204/03/2023
EI208/03/2023

 

Table 2: Dates

Date

13/01/23
27/01/23
10/02/23
24/02/23
07/03/23
21/03/23
05/04/23

 

For example

 

Table 3: model with version categorized

 

EI117/01/2023 27/01/23
EI119/01/2023 27/01/23
EI128/01/2023 10/02/23
EI102/02/2023 10/02/23
EI205/02/2023 10/02/23
EI226/02/2023 07/03/23
EI204/03/2023 07/03/23

 

etc...

 

Below is the Code that works how can I write it in power query?

 

DateAg = CALCULATE ( MIN ( 'Date'[DateList]), FILTER ( 'Date', 'Date'[DateList] >= 'EI'[Version] ) )

1 ACCEPTED SOLUTION
Payeras_BI
Solution Sage
Solution Sage

Hi @JL0101 ,

A possible solution:

Payeras_BI_0-1683648054183.png

Make sure both Version and DateList columns are set to type date.

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

View solution in original post

2 REPLIES 2
JL0101
Helper II
Helper II

Perfect, thank you!

Payeras_BI
Solution Sage
Solution Sage

Hi @JL0101 ,

A possible solution:

Payeras_BI_0-1683648054183.png

Make sure both Version and DateList columns are set to type date.

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.