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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.