Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Guys I have the following table:
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
Solved! Go to Solution.
@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] )
)
)
TO =
CALCULATE (
MAX ('stage_history'[STAGE_NAME]),
FILTER (
ALLEXCEPT ( 'stage_history', 'stage_history'[DEAL_ID] ),
'stage_history'[DATE_CREATE] > EARLIER ( 'stage_history'[DATE_CREATE] )
)
)
TO =
CALCULATE (
MAX ('stage_history'[STAGE_NAME]),
FILTER (
ALLEXCEPT ( 'stage_history', 'stage_history'[DEAL_ID] ),
'stage_history'[DATE_CREATE] > EARLIER ( 'stage_history'[DATE_CREATE] )
)
)
Hi
With the sample data csv file, what is the final output expected.
Cheers
CheenuSing
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.
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] )
)
)
Amazing, thank-you!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
72 | |
38 | |
31 | |
26 |
User | Count |
---|---|
94 | |
50 | |
43 | |
40 | |
35 |