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! Request now

Reply
htsvhwave
Helper II
Helper II

Lookup a value based on date between start and end date

Hi

i want help to calute the period column in the timesheet, which can be found in the absence period tabel, how do i do that

Timesheets

Employee

Date 

Period

John

3-1-2019

Short period

John

4-1-2020

Long period

Chris

8-1-2019

Short period

Chris

15-1-2019

Medium period

 

Absence period

Employee

Period

Start Date

End Date

John

Short period

1-1-2019

3-1-2019

John 

Long period

4-1-2020

29-1-2020

Chris

Short period

6-1-2019

9-1-2019

Christ

Medium period

12-1-2020

20-1-2019

4 REPLIES 4
dk_dk
Super User
Super User

The solution I can think of is not very elegant but it should work:

Follow the tutorial here 

https://amitchandak.medium.com/power-query-get-all-dates-between-the-start-and-end-date-9ad6a84cf5f2

to transform your Absence Period table in query (duplicate/reference the original query in case you want to keep the original format intact for other visuals or measures).

In the transformed Absence period create a Key column which concatenates Employee and the Date column that results from the transformation.

Create the same column in Timesheets table. Then you should be able to use lookupvalue, or connect the two tables together in the model and get the period directly from your transformed Absence period table.

Let me know if you have any questions.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





danextian
Super User
Super User

Hi @htsvhwave ,

Please try this:

Period2 = 
CALCULATE (
    MAX  ( 'Absence period'[Period] ),
    FILTER (
        'Absence period',
        'Absence period'[Employee] = EARLIER ( Timesheets[Employee] )
            && EARLIER ( Timesheets[Date] ) >= 'Absence period'[Start Date]
            && EARLIER ( Timesheets[Date] ) <= 'Absence period'[End Date]
    )
)

 

Please take note of the following in your sample data:

No result for row 4 as your start date > than your end date

Christ instead of Chris

danextian_1-1698056252412.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

When i try to use your fomula i cant call the column after using the Earlier function

Which table are you entering this formula in? And also, this is supposed to be a calculated column and not a measure. You can't use EARLIER within a measure unless it is used within  a virtual table.

Please see attached sample pbix for details:

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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.

Top Solution Authors