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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to "jump" from a column's last record to the across data on another column?

Hello everyone,

 

Today, I would like to share the most specific issue with you that I've encountered.

I'm trying to calculate the open lead time of each ongoing order in the production unit of my organization.

I would like you to have a look at the below table to understand my issue.

 

Order NumberStep IDLast Transaction Date of The StepTransaction's Scheduled End Date
AXBY900116/11/20214/4/2022
AXBY900126/11/20214/4/2022
AXBY900136/11/20214/6/2022
AXBY900146/14/20214/8/2022
AXBY900156/14/20214/11/2022
AXBY900166/22/20214/12/2022
AXBY900177/9/20214/14/2022
AXBY900187/9/20214/20/2022
AXBY900197/9/20214/21/2022
AXBY9001107/12/20214/22/2022
AXBY9001117/22/20214/25/2022
AXBY9001127/23/20214/25/2022
AXBY9001137/23/20214/26/2022
AXBY9001147/23/20214/27/2022
AXBY9001157/23/20214/28/2022
AXBY9001167/23/20214/28/2022
AXBY9001177/26/20214/29/2022
AXBY9001188/10/20215/3/2022
AXBY9001198/11/20215/4/2022
AXBY900120 5/6/2022
AXBY900121 5/9/2022
AXBY900122 5/11/2022
AXBY900123 5/11/2022
AXBY900124 5/13/2022

 

As you can see, the "Last Transaction Date" column shows the actual end date of the order's steps.

However, the Production planning team has already calculated each end date of the order's every step on the Transaction's Scheduled End Date before production started.

 

Here is the need to calculate Open Lead Time;

The duration between the "last record" of the scheduled end date column (5/13/2022 can be calculated via MAXX function) and the date which is opposite of the "last record" of the last transaction date of the step column.

 

The red one is also calculated via the MAXX function. However, I need only to jump the opposite of the last transaction date column's last record somehow which is 5/4/2022. After that, I will be able to calculate the duration between these two dates (orange ones).

 

I hope it would be understandable for you and any guidance, comment can help me a lot.

I appreciate your answers in advance.

 

Best

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@Anonymous 

pls try this

Measure = DATEDIFF(maxx(FILTER('Table','Table'[Order Number]=max('Table'[Order Number])&&'Table'[Last Transaction Date of The Step]=max('Table'[Last Transaction Date of The Step])),'Table'[Transaction's Scheduled End Date]),max('Table'[Transaction's Scheduled End Date]),DAY)

1.PNG





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

Proud to be a Super User!




View solution in original post

wdx223_Daniel
Super User
Super User

Open_Lead_Time=VAR _max_Schedule_End_Date=CALCULATE([Transaction's Scheduled End Date],ALLEXCEPT(FactTable,FactTable[Order Number])) VAR _max_Actual_End_Date=CALCULATE([Last Transaction Date of The Step],ALLEXCEPT(FactTable,FactTable[Order Number])) RETURN IF([Last Transaction Date of The Step]=_max_Actual_End_Date,_max_Schedule_End_Date-_max_Actual_End_Date)

View solution in original post

7 REPLIES 7
wdx223_Daniel
Super User
Super User

Open_Lead_Time=VAR _max_Schedule_End_Date=CALCULATE([Transaction's Scheduled End Date],ALLEXCEPT(FactTable,FactTable[Order Number])) VAR _max_Actual_End_Date=CALCULATE([Last Transaction Date of The Step],ALLEXCEPT(FactTable,FactTable[Order Number])) RETURN IF([Last Transaction Date of The Step]=_max_Actual_End_Date,_max_Schedule_End_Date-_max_Actual_End_Date)

Anonymous
Not applicable

Hello Daniel,

 

Your solution works also correctly...

Thank you for your big support!

 

ryan_mayu
Super User
Super User

@Anonymous 

pls try this

Measure = DATEDIFF(maxx(FILTER('Table','Table'[Order Number]=max('Table'[Order Number])&&'Table'[Last Transaction Date of The Step]=max('Table'[Last Transaction Date of The Step])),'Table'[Transaction's Scheduled End Date]),max('Table'[Transaction's Scheduled End Date]),DAY)

1.PNG





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

Proud to be a Super User!




Anonymous
Not applicable

Unfortunately, It doesn't work. I think it was my mistake because I didn't share all rows of the table with you. Completely, there is more than one order number in this table. And when I try to check the equality of Order number and MAX(Order Number), it did not work. Would it be the problem?

 

Thanks in advance

Best regards.

@Anonymous

it should work. I added another order number and had a test.

pls see the attachment below





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

Proud to be a Super User!




Anonymous
Not applicable

That was my mistake, your solution is correct my mate!

You made my day. I wish that I have a chance to order a beer for you... 🙂

 

I really thank you very much...

you are welcome 🙂





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

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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