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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
cawhiteside
Regular Visitor

Lookup by Datetime

Hi - I have two tables, one that records downtime events at a machine, and another that records when a machine started to produce a certain part number. I'm trying to create a column that finds what part number was associated with the downtime event. Right now I am using this DAX formula:

Material = 
VAR OrderDateTime = [Adjusted_Start]
RETURN CALCULATE(
FIRSTNONBLANK(ProductionOrderLog[MaterialNo], 0),
CALCULATETABLE(
LASTNONBLANK(ProductionOrderLog[StartDateLocal], 0),
ProductionOrderLog[StartDateLocal] <= OrderDateTime
)
)

This formula works if a machine started making a part number in the same day, however once a new day is started, it will not pull any part number until a new part is started that day. See below for examples.

Part Number Job Table:

2020-03-02 10_02_05-Downtime Report - Power BI Desktop.png

 

 

 

 

 

 

 

 

 

 

Downtime Event Table:

2020-03-02 10_03_36-Downtime Report - Power BI Desktop.png

Can anyone please help me with this? Thanks in advance.

- Connor

1 ACCEPTED SOLUTION
cawhiteside
Regular Visitor

I managed to fix this by deleting the relationship between the date in the table that recorded part number jobs and my custom date table in the report. Thanks anyway for the help!

View solution in original post

5 REPLIES 5
cawhiteside
Regular Visitor

I managed to fix this by deleting the relationship between the date in the table that recorded part number jobs and my custom date table in the report. Thanks anyway for the help!

Anonymous
Not applicable

Create column in second table using lookupvalue function.

 

https://docs.microsoft.com/en-us/dax/lookupvalue-function-dax

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

Hi Pravin - I'm afraid that gives me the same problem. If a part started running on a machine at 11pm and the machine goes down the following day at 1am, the part number column will show up blank.

Anonymous
Not applicable

Share data in text so that i can work on it.
Also share your expected output.

Thanks
Pravin

Sorry, the LOOKUPVALUE function actually isn't returning anything.  Here's what I tried:

Material = 
LOOKUPVALUE(
ProductionOrderLog[MaterialNo],
ProductionOrderLog[StartDateLocal],
'Production Events'[Adjusted_Start]
)
 

See below for expected results. The part number column should show 2002155 for all events on entity 9 since the first time it started running (2/27/20 at 7am as shown in second picture).

img1.pngimg2.png

Helpful resources

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