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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sarveshpandey23
Frequent Visitor

End date of one above row should be start date below row

In the shared screenshot, there is two column. STARTDTM (start date) and ENDDTM (end date).

Enddate to 1st row must be start date of 2nd row.

Enddate to 2nd row must be start date of 3rd row and it goes on.

 

 

Screenshot (1086).png

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @sarveshpandey23 ,

Is this your expected result?

table result.png

If so, you can use this formula to create a calculated column:(Create an index column as a mark in power query firstly)

End Date =
VAR _current = 'Table'[Index]
VAR _col =
    CALCULATE (
        MAX ( 'Table'[STARTDTM] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[EMPLOYEEID] = EARLIER ( 'Table'[EMPLOYEEID] )
                && 'Table'[Index] = _current + 1
        )
    )
RETURN
    _col

 

Sample file is attached that hopes to help, pelase check and try it: 

 End date of one above row should be start date below row.pbix 

 

Best Regards,
Yingjie Li

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

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @sarveshpandey23 ,

Is this your expected result?

table result.png

If so, you can use this formula to create a calculated column:(Create an index column as a mark in power query firstly)

End Date =
VAR _current = 'Table'[Index]
VAR _col =
    CALCULATE (
        MAX ( 'Table'[STARTDTM] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[EMPLOYEEID] = EARLIER ( 'Table'[EMPLOYEEID] )
                && 'Table'[Index] = _current + 1
        )
    )
RETURN
    _col

 

Sample file is attached that hopes to help, pelase check and try it: 

 End date of one above row should be start date below row.pbix 

 

Best Regards,
Yingjie Li

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

edhans
Super User
Super User

Try this calculated column:

End Date = 
VAR CurrentStartDate = Dates[Start Date]
VAR NewEndDate = 
    MINX(
        FILTER(
            ALL(Dates[Start Date]),
            Dates[Start Date] > CurrentStartDate
        ),
        Dates[Start Date]
    )
RETURN
    NewEndDate

Returns this:

2020-05-19 07_35_38-Untitled - Power BI Desktop.png



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

You'll need to supply data (see links below, no screenshots) and what the expected output is and why (screenshots ok for that). My method works for the date column, but you apparently need it by employee, pay code, or other stuff. None of that was explained in the original post.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Hi edhans,

 

i tried your solution but i doesn't work. 

 

Here it the ouput.Screenshot (1088).png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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