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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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

v-xuxinyi-msft
Community Support
Community Support

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
v-xuxinyi-msft
Community Support
Community Support

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors