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
tahechadv_2022
Helper II
Helper II

How to create a column in a table with the next value of a column?

Guys I have the following table:

tahechadv_2022_0-1701800830709.png

 

I want to create a Sankey visual, the STAGE_NAME column would be the SOURCE column, and I want to create the DESTINATION column.

But in order to create this column, I need a DAX code to iterate over each DEAL_ID and capture the next STAGE_NAME based on the column DATE_CREATE. Every time the DEAL_ID changes, I won't need the next phase.

 

Trying to make it clear, all need all the phases (STAGE_NAME) that a card (DEAL_ID) passed in cronological order. Following the order of the sankey visual: SOURCE and DESTINATION. My problem is: how to create the DESTINATION column.

 

Link of the table:

https://drive.google.com/file/d/1mi0dAjGnKbxHa7zn7CM9zx7YjyfxeDOy/view?usp=sharing

2 ACCEPTED SOLUTIONS

@tahechadv_2022  you can use a measure like this which doubles as a calculated column too.

 

Measure 2 = 
CALCULATE (
    MAX ( 'Table'[stagename] ),
    ALL ( 'Table' ),
    OFFSET (
        1,
        ALL ( 'Table'[dealId], 'Table'[date_create] ),
        ORDERBY ( 'Table'[date_create], ASC ),
        ,
        PARTITIONBY ( 'Table'[dealId] )
    )
)

 

 

smpa01_0-1701975233435.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

tahechadv_2022
Helper II
Helper II

Hi guys, based on another dax query of mine I found another way to do the same thing:
 
TO =

CALCULATE (

    MAX ('stage_history'[STAGE_NAME]),

    FILTER (

        ALLEXCEPT ( 'stage_history', 'stage_history'[DEAL_ID] ),

        'stage_history'[DATE_CREATE] > EARLIER ( 'stage_history'[DATE_CREATE] )

    )

)

View solution in original post

5 REPLIES 5
tahechadv_2022
Helper II
Helper II

Hi guys, based on another dax query of mine I found another way to do the same thing:
 
TO =

CALCULATE (

    MAX ('stage_history'[STAGE_NAME]),

    FILTER (

        ALLEXCEPT ( 'stage_history', 'stage_history'[DEAL_ID] ),

        'stage_history'[DATE_CREATE] > EARLIER ( 'stage_history'[DATE_CREATE] )

    )

)
CheenuSing
Community Champion
Community Champion

Hi

With the sample data csv file, what is the final output expected.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

I want to create a column named TO, this column must contain the name of the next STAGE_NAME according to the cronology of DATE_CREATE. 

tahechadv_2022_1-1701972606374.png

The last DEAL_ID must be empty, because this card didn't move anywhere else.

@tahechadv_2022  you can use a measure like this which doubles as a calculated column too.

 

Measure 2 = 
CALCULATE (
    MAX ( 'Table'[stagename] ),
    ALL ( 'Table' ),
    OFFSET (
        1,
        ALL ( 'Table'[dealId], 'Table'[date_create] ),
        ORDERBY ( 'Table'[date_create], ASC ),
        ,
        PARTITIONBY ( 'Table'[dealId] )
    )
)

 

 

smpa01_0-1701975233435.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Amazing, thank-you!

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.