Forum Discussion
Previous row value fetching
Hi, i created a new column named
attaching a screenshot for reference
Hi Subhash08
Getting the previous row number in Power BI is not as easy as in Excel, but there are multiple ways to achive this, and the following is one example. You can achieve your required output by creating a separate calculated table referencing with staggering index and the value you want to bring in the next row,
Create a relationship between the index calculated table and the data table using the staggered previous row in the calculated table as the reference key.
Then create a measure, concatenateXing the column you want to stagger the rows.
The output like below will be produced.
I attach the pbix as an example. I am sure that there are many other sophisticated ways to achive this, too.
- Anonymous2 years ago
Hi Subhash08
Thanks for the reply from DataNinja777 . Here I have another idea in mind, and I would like to share it for reference.
I used a portion of your data and then ran the following test.
Create several calculated columns as follow
Column = VAR _previous = 'Table'[Sequence] VAR _maxs = CALCULATE(MAX([Sequence]), FILTER('Table', [New Item No_] <> BLANK() && _previous > [Sequence])) RETURN _maxsnuova colonna new = IF([New Item No_] <> BLANK(), [New Item No_], LOOKUPVALUE('Table'[New Item No_], 'Table'[Sequence], 'Table'[Column]))Result:
Best Regards,
Yulia XuIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- DataNinja777Super User
Hi Subhash08
Getting the previous row number in Power BI is not as easy as in Excel, but there are multiple ways to achive this, and the following is one example. You can achieve your required output by creating a separate calculated table referencing with staggering index and the value you want to bring in the next row,
Create a relationship between the index calculated table and the data table using the staggered previous row in the calculated table as the reference key.
Then create a measure, concatenateXing the column you want to stagger the rows.
The output like below will be produced.
I attach the pbix as an example. I am sure that there are many other sophisticated ways to achive this, too.
- AnonymousNot applicable
Hi Subhash08
Thanks for the reply from DataNinja777 . Here I have another idea in mind, and I would like to share it for reference.
I used a portion of your data and then ran the following test.
Create several calculated columns as follow
Column = VAR _previous = 'Table'[Sequence] VAR _maxs = CALCULATE(MAX([Sequence]), FILTER('Table', [New Item No_] <> BLANK() && _previous > [Sequence])) RETURN _maxsnuova colonna new = IF([New Item No_] <> BLANK(), [New Item No_], LOOKUPVALUE('Table'[New Item No_], 'Table'[Sequence], 'Table'[Column]))Result:
Best Regards,
Yulia XuIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.