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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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. 

Whiskeybar
Advocate I
Advocate I

I have the same problem.. 

v-ljerr-msft
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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