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

How to shift down 1 row for only 1 column in M?

Hi,

 

I have a similar dataset as below (row 0 is the headers here):

Column1Column2Column3Column4
DateColumn1Column2Column3
20180320ReportNameGrossProfit
20180319EvidenceA53
20180318EvidenceB108
20180317EvidenceC1513

 

 

After extracting data out of a multiple excel files, I'm at the point in query where I'm ready to promote headers but as you can see, it's not clean. I either want to:
1. Shift column 1 down one, remove the 1st row and promote the new 1st row to headers

2. Shift all the other columns (except column 1) up 1 and then promote the 1st row to headers

 

Is there a way to shift up/down for only 1 column? I've read an example of using index+nested joins but I got lost and it didn't make sense.

 

 

2 ACCEPTED SOLUTIONS
Zubair_Muhammad
Community Champion
Community Champion

Hi @powerbiuser101

 

I know of one way.. I do not know if it is ideal

 

Please check the attached file here

 

Shift 1 row 1 column.png


Regards
Zubair

Please try my custom visuals

View solution in original post

@powerbiuser101

 

Here is the process

 

1) Create a duplicate Query

2) Remove the first column in original Query

3) Remove the other 3 Columns in Duplicate Query

4) Promote the relevant rows as headers in both Queries

5) Add an Index Column in both Queries

6) Now merge both queries using full outer join


Regards
Zubair

Please try my custom visuals

View solution in original post

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

Hi @powerbiuser101

 

I know of one way.. I do not know if it is ideal

 

Please check the attached file here

 

Shift 1 row 1 column.png


Regards
Zubair

Please try my custom visuals

@powerbiuser101

 

Here is the process

 

1) Create a duplicate Query

2) Remove the first column in original Query

3) Remove the other 3 Columns in Duplicate Query

4) Promote the relevant rows as headers in both Queries

5) Add an Index Column in both Queries

6) Now merge both queries using full outer join


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

This solution is manual but what we should do to dynamically shift 1 column down or up?

Anonymous
Not applicable

@Anonymous 
There's a way to do in Power Query, assuming there is something that will trigger when the data starts vs. any other rows that should be removed.

 

 Basically would write function that would look for this "anchor" and remove the rows above it. It would be flexible enough to not always assume it would only 1 row. 

 

If you start a new post, and add some sample files I can probably put a solution together. If you do make a new post ( I wouldnt clog up this post) please be sure to tag me.

 

-Nick

Works perfectly, thanks @Zubair_Muhammad!

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.