Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Subhash08
Regular Visitor

Previous row value fetching

Hi, i created a new column named

nuova colonna new, the condition --> if my new_item_no column current row is blank, I want to fetch the previous row value. please help me

attaching a screenshot for reference

refrence.png

 

2 ACCEPTED SOLUTIONS
DataNinja777
Super User
Super 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, 

DataNinja777_1-1713613060798.png

 

 

DataNinja777_3-1713613383197.png

 

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. 

DataNinja777_4-1713613631080.png

 

The output like below will be produced.  

DataNinja777_0-1713612950039.png

I attach the pbix as an example.  I am sure that there are many other sophisticated ways to achive this, too. 

 

View solution in original post

Anonymous
Not 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.

vxuxinyimsft_0-1713768079495.png

 

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
_maxs

 

nuova colonna new = IF([New Item No_] <> BLANK(), [New Item No_], LOOKUPVALUE('Table'[New Item No_], 'Table'[Sequence], 'Table'[Column]))

 

Result:

vxuxinyimsft_1-1713768248090.png

 

Best Regards,
Yulia Xu

 

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

View solution in original post

2 REPLIES 2
Anonymous
Not 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.

vxuxinyimsft_0-1713768079495.png

 

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
_maxs

 

nuova colonna new = IF([New Item No_] <> BLANK(), [New Item No_], LOOKUPVALUE('Table'[New Item No_], 'Table'[Sequence], 'Table'[Column]))

 

Result:

vxuxinyimsft_1-1713768248090.png

 

Best Regards,
Yulia Xu

 

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

DataNinja777
Super User
Super 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, 

DataNinja777_1-1713613060798.png

 

 

DataNinja777_3-1713613383197.png

 

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. 

DataNinja777_4-1713613631080.png

 

The output like below will be produced.  

DataNinja777_0-1713612950039.png

I attach the pbix as an example.  I am sure that there are many other sophisticated ways to achive this, too. 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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