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 September 15. Request your voucher.

Reply
TK12345
Resolver I
Resolver I

Find value based on previous rows and other column

Hi guys,

I need help with the following:

I need to create the column: expected outcome enddate

This column needs to be based on the column cat. The expected outcome of the first row of each Cat needs to be empty. As well as the first row of each new type. The expected outcome enddate previous type needs to be filled if the previous row has the same  cat and the same Type. One addition to that, it is possible that within 1 cat, the type changes but has been ended on a previous row above. So for example row 14 gives uit 27-12-2020, because the cat is still 4 and the type 4 has an enddate two rows above. 

I have tried with duplicate table add index and merge back. Did not work out great. 

TK12345_0-1667506830083.png

 



Who could help me, you could also use startdate and id maybe. 

 

 

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @TK12345 ,

 

Please try:

First, create an index column:

vjianbolimsft_0-1667539764809.png

Please try:

Column =
VAR _a =
    MINX (
        FILTER (
            'Table',
            [Cat] = EARLIER ( 'Table'[Cat] )
                && [Type] = EARLIER ( 'Table'[Type] )
        ),
        [Index]
    )
VAR _b =
    MAXX (
        FILTER (
            'Table',
            [Cat] = EARLIER ( 'Table'[Cat] )
                && [Type] = EARLIER ( 'Table'[Type] )
                && [Index] < EARLIER ( 'Table'[Index] )
        ),
        [Index]
    )
RETURN
    IF (
        [Index] = _a,
        BLANK (),
        MAXX ( FILTER ( 'Table', [Index] = _b ), [Enddate] )
    )

Final output:

vjianbolimsft_1-1667540167155.png

Best Regards,

Jianbo Li

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

Hi thanks for your reply,

For now it works, but is it possible to do this in the Power Query, because of the next steps I have to do.

Hi thanks for your reply,

For now it works, but is it possible to do this in the Power Query, because of the next steps I have to do.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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