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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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...

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.