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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
sunc
New Member

Row Index being Reordered After Merge.

Hi Community

 

 Just playing around with PowerBI, but I ran into something that I confused about.

 

Basically I am trying to shape the data so that for a given row i the previous two rows ( and their respective row values, I've only show year for example) will appear in the row as two new columns kind of like the lag window function used in SQL. I decided to use a merge method where I merge the table with itself using the indexing as the join paremeter. My Row Indexes are t (current row), t-1 (1 previous row) and t-2 (previous two rows). Represented below: 

p1.JPG

 

 

I've only provided a small snippet basically there is a row index for every group

Group  Row t   Row t-1 Row t-2

A               0            -1         -2        

B               1             0          -1

C               2             1           0

 

This works for some group but noticed it doesn't work for some others after I expand. 
In one of the scenarios after merging I look at the output before expanding it shows what should happen, in this case for year 2015 the picture displays the possible new columns appended after merging.

p2.JPG

But when I expand  - the indexes change and the ordering becomes messed if I want to append row t-2.

p3.JPG

 

I think i would just have to reset the indexes when i do another merge (would like to avoid that) but I just want to know why would this occur.

 

Thanks!

4 REPLIES 4
Anonymous
Not applicable

I noticed this issue too. Trying to build an index so that I can reference the same postion without it changing. But after a merge, it canges. 

Anonymous
Not applicable

I have the same problem.. 

v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @sunc,

 

Could post some sample data and all the power query(M formula) you're applying to reproduce this issue, so that we can further investigate on this issue? It's better to share a sample pbix file. You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading. Smiley Happy

 

Regards

any solution?

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.