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
Anonymous
Not applicable

Find the next Stop Date

Hi,

 

I try to find the next "Stop Date". I have got the following structure

 

PositionTypeStart Date
10End07.11.2019 23:58
10End07.11.2019 23:57
10Start07.11.2019 23:57
10Start07.11.2019 23:56
20End07.11.2019 23:55
20Start07.11.2019 23:54
10End07.11.2019 23:54
20End07.11.2019 23:53
10Start07.11.2019 23:52
10End07.11.2019 23:50

 

So I add an Index to column to share the positions and and the start or and type.

 

PositionTypeStart DateIndex
10End07.11.2019 23:584
10End07.11.2019 23:573
10Start07.11.2019 23:573
10Start07.11.2019 23:562
20End07.11.2019 23:552
20Start07.11.2019 23:541
10End07.11.2019 23:542
20End07.11.2019 23:531
10Start07.11.2019 23:521
10End07.11.2019 23:501

 

My idea was to add a second column and add the Date with type "End" in this column where Position = Position and Index = Index

But as you can see, I have got more End Dates than Start Dates. So in this case my and End Date is after my Start Date...

 

PositionTypeStart DateIndexEnd Date
10End07.11.2019 23:584 
10End07.11.2019 23:573 
10Start07.11.2019 23:57307.11.2019 23:57
10Start07.11.2019 23:56207.11.2019 23:54
20End07.11.2019 23:552 
20Start07.11.2019 23:54107.11.2019 23:53
10End07.11.2019 23:542 
20End07.11.2019 23:531 
10Start07.11.2019 23:52107.11.2019 23:50
10End07.11.2019 23:501 

 

But I like to get this

 

PositionTypeStart DateLike to get
10End07.11.2019 23:58 
10End07.11.2019 23:57 
10Start07.11.2019 23:5707.11.2019 23:58
10Start07.11.2019 23:5607.11.2019 23:57
20End07.11.2019 23:55 
20Start07.11.2019 23:5407.11.2019 23:55
10End07.11.2019 23:54 
20End07.11.2019 23:53 
10Start07.11.2019 23:5207.11.2019 23:54
10End07.11.2019 23:50 

 

Any ideas how to find the next Date with type End depending on the Position?

 

Best regards

Timo

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Anonymous ,

You can use the following measure formula to achieve your requirement:

NextDate =
VAR currType =
    SELECTEDVALUE ( 'Table'[Type] )
RETURN
    IF (
        currType = "Start",
        CALCULATE (
            MIN ( 'Table'[Start Date] ),
            FILTER ( ALLSELECTED ( 'Table' ), [Start Date] > MAX ( 'Table'[Start Date] ) ),
            VALUES ( 'Table'[Position] )
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @Anonymous ,

You can use the following measure formula to achieve your requirement:

NextDate =
VAR currType =
    SELECTEDVALUE ( 'Table'[Type] )
RETURN
    IF (
        currType = "Start",
        CALCULATE (
            MIN ( 'Table'[Start Date] ),
            FILTER ( ALLSELECTED ( 'Table' ), [Start Date] > MAX ( 'Table'[Start Date] ) ),
            VALUES ( 'Table'[Position] )
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.