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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
AndyDD_UK
Helper III
Helper III

DAX for advanced look up

(Simplified) I have 2 tables and want to look-up the charge out rate applicable for each member of staff, based on the invoice date:

 

Table 1:

Col A: invoice date

Col B: employee

Col C: I want to look up their charge out rate applicable for when the job was done

 

Table 2:

Column A: employee

Column B:  date

Column C: rate

 

Table 2 Example:

Col A.....Col B.....Col C

John     15/01/2022.    100

John      03/07/2022.    120

Here you see that John's charge out rate is £100 from 15/01/2022 to 02/07/2022 where it then changes to £120

 

Is there a way of working this out the rate or does Table 2 need to include all dates in order to find a match ?

 

 

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

Hi, @AndyDD_UK 

Please try formula like below:

Look_up_date =
CALCULATE (
    MAX ( Table2[invoice date] ),
    FILTER (
        ALL ( Table2 ),
        Table2[invoice date] <= MAX ( Table1[invoice date] )
            && Table2[employee] = MAX ( Table1[employee] )
    )
)
Look_up_rate =
CALCULATE (
    MAX ( Table2[Rate] ),
    FILTER (
        Table2,
        Table2[employee] = MAX ( Table1[employee] )
            && Table2[invoice date] = [Look_up_date]
    )
)

Best Regards,
Community Support Team _ Eason

View solution in original post

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi, @AndyDD_UK 

Please try formula like below:

Look_up_date =
CALCULATE (
    MAX ( Table2[invoice date] ),
    FILTER (
        ALL ( Table2 ),
        Table2[invoice date] <= MAX ( Table1[invoice date] )
            && Table2[employee] = MAX ( Table1[employee] )
    )
)
Look_up_rate =
CALCULATE (
    MAX ( Table2[Rate] ),
    FILTER (
        Table2,
        Table2[employee] = MAX ( Table1[employee] )
            && Table2[invoice date] = [Look_up_date]
    )
)

Best Regards,
Community Support Team _ Eason

amitchandak
Super User
Super User

@AndyDD_UK , Based on what I got.

You need a new column first

end Date = minx(filter(Table, [Name] = earlier([Name]) && [Date] > earlier([date])), [Date]) -1

 

Then use the logic in blog or file to expand

 

https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-o...

 

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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