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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.