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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

New End date column based on start date

Hi all,

 

I want to add a column that containt the end date from the folliwng data.

 

Code

Phase

Date start

1122

Request

10-03-21 11:00

1122

Accepted

10-04-21 12:15

1122

Planned

12-04-21 13:21

5588

Request

25-03-21 18:13

5588

Accepted

30-03-21 14:22

9977

Request

4-04-21 9:12

9977

Accepted

8-04-21 17:18

9977

Planned

9-04-21 15:30

9977

Go

5-05-21 18:00

 

The end date is de date from the previous phase. so for for example my end result looks like below.

 

Code

Phase

Date start

Date End

9977

Request

4-04-21 9:12

8-04-21 17:18

9977

Accepted

8-04-21 17:18

9-04-21 15:30

9977

Planned

9-04-21 15:30

5-05-21 18:00

9977

Go

5-05-21 18:00

 

 

The "Date End" Is the "Date Start" value from the next phase. 

I Tried this with Dax but I only get the datediff from the last date. I don't know how to do this in M language for each code row.

It needs to be in Power Query so I can add the column to my chart. 

 

Yours faithfully,

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please check my attachment.

 

1.Refer to this article to get a ranking by category. And copy the original table to get the second table, the first table sorting starts from 2, and the second table sorting starts from 1.

2.png1.png

 

2.Then merge two tables.

3.png

 

3.Expand the table

Screenshot 2021-04-22 173507.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

Please check my attachment.

 

1.Refer to this article to get a ranking by category. And copy the original table to get the second table, the first table sorting starts from 2, and the second table sorting starts from 1.

2.png1.png

 

2.Then merge two tables.

3.png

 

3.Expand the table

Screenshot 2021-04-22 173507.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please try to write the below calculated measure.

 

Picture6.png

 

 

Date End =
VAR currentcode =
MAX ( Data[Code] )
VAR currentstartdate =
MAX ( Data[Date Start] )
VAR _firstnonblankvalue =
CALCULATE (
FIRSTNONBLANKVALUE ( Data[Date Start], SELECTEDVALUE ( Data[Date Start] ) ),
FILTER (
ALL ( Data ),
Data[Code] = currentcode
&& Data[Date Start] > currentstartdate
)
)
RETURN
COALESCE ( _firstnonblankvalue, "" )

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: https://www.linkedin.com/in/jihwankim1975/


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Hi Ihwan,

 

Thank you for your reply. Unfortunately 

Your solutions works in dax But I want to make this in Powet Query, because then I have a column which I can add on my gantt. The gannt chart doesnt accept the dax formule

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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