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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
ThomasWeppler
Impactful Individual
Impactful Individual

Lookup function for max date

Hi power Bi community

I have two tables and I need to get data from one of them to the other.

The tables are called Data and chechkin.

 

In the data table I have a the following rows.

Index: (number)

Customer_id: (number)

Answer_date: (date)

 

The chechkin table have the following rows

Index: (number)

Customer_id: (number)
Chechkin_date: (date)

 

I want to make a lookup function where I find the last chechin_date in the chechkin_table with a date that comes before the answer date.

 

I have tried with this Dax:

LastChechIndate = lookupvalue('Checkin'[Chechkin_date], 'Checkin'[Customer_id], 'Data'[Customer_id])

The problem is that I get an error becuase the Dax returns multiple values. Can anyone help me with this issue?
All help is greatly appreciated.

1 ACCEPTED SOLUTION
aduguid
Super User
Super User

Create a calculated column in the Data table to store the last Chechkin_date.

 

LastChechkinDate = 
VAR CurrentCustomerID = 'Data'[Customer_id]
VAR CurrentAnswerDate = 'Data'[Answer_date]
RETURN
    MAXX(
        FILTER(
            'Checkin',
            'Checkin'[Customer_id] = CurrentCustomerID &&
            'Checkin'[Chechkin_date] < CurrentAnswerDate
        ),
        'Checkin'[Chechkin_date]
    )

 

 

 

 

View solution in original post

2 REPLIES 2
aduguid
Super User
Super User

Create a calculated column in the Data table to store the last Chechkin_date.

 

LastChechkinDate = 
VAR CurrentCustomerID = 'Data'[Customer_id]
VAR CurrentAnswerDate = 'Data'[Answer_date]
RETURN
    MAXX(
        FILTER(
            'Checkin',
            'Checkin'[Customer_id] = CurrentCustomerID &&
            'Checkin'[Chechkin_date] < CurrentAnswerDate
        ),
        'Checkin'[Chechkin_date]
    )

 

 

 

 

Thanks for the answer.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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