Forum Discussion
Deep lookup over column pair
- 6 years ago
Hi Anonymous ,
Is the screenshot your expected output?
Just create a calculated column for getting the first step:
Column = IF('Table'[previous_step] = BLANK(),'Table'[step_id],BLANK())Then use dax to fill down:
first_step = VAR LastNonBlankStep = CALCULATE ( LASTNONBLANK ( 'Table'[step_id], 1 ), FILTER ( ALL ( 'Table' ), 'Table'[step_id] <= EARLIER ( 'Table'[step_id] ) && NOT ( ISBLANK ( 'Table'[Column] ) ) ) ) RETURN CALCULATE ( MAX ( 'Table'[Column] ), FILTER ( ALL ( 'Table' ), 'Table'[step_id] = LastNonBlankStep ) )For more details, please refer to the pbix file:https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/ERXKTCCXNOVCrS1Fwsw6W4IB91H3Ib8IaZDbBvb8hn6uYg?e=hKvZOS
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Hi Anonymous ,
I still can't get the expected output you want from your description. Would you please show us more details and expected output based on your sample data?
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Let's generalize it further.
Input:
| step_id | previous_step |
| 1 | |
| 2 | 1 |
| 3 | 2 |
| 4 | |
| 5 | 4 |
| 6 | 4 |
| 7 | 6 |
| 8 | 3 |
Output:
| step_id | previous_step | first_step |
| 1 | 1 | |
| 2 | 1 | 1 |
| 3 | 2 | 1 |
| 4 | 4 | |
| 5 | 4 | 4 |
| 6 | 4 | 4 |
| 7 | 6 | 4 |
| 8 | 3 | 1 |
- v-deddai1-msft6 years ago
Community Support
Hi Anonymous ,
Is the screenshot your expected output?
Just create a calculated column for getting the first step:
Column = IF('Table'[previous_step] = BLANK(),'Table'[step_id],BLANK())Then use dax to fill down:
first_step = VAR LastNonBlankStep = CALCULATE ( LASTNONBLANK ( 'Table'[step_id], 1 ), FILTER ( ALL ( 'Table' ), 'Table'[step_id] <= EARLIER ( 'Table'[step_id] ) && NOT ( ISBLANK ( 'Table'[Column] ) ) ) ) RETURN CALCULATE ( MAX ( 'Table'[Column] ), FILTER ( ALL ( 'Table' ), 'Table'[step_id] = LastNonBlankStep ) )For more details, please refer to the pbix file:https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/ERXKTCCXNOVCrS1Fwsw6W4IB91H3Ib8IaZDbBvb8hn6uYg?e=hKvZOS
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai