for display only
Big Blue Interactive The Corner Forum  
Back to the Corner

Archived Thread

NFT: Excel Question - should be easy

Matt M. : 8/17/2022 10:36 am
I have a table that comes to us in descending order on both the x-axis and y-axis. We need both the rows and columns in ascending order, both starting with 0,0

X-axis comes to us as 16,15,14...0
y-axis comes to us as 85,84,83,82...0

We need 0-16 on the x-axis and 0-85 on y

So, not a straight transpose and we receive this via Excel and would be working with it in Excel. Is there a simple way to do this, as the transpose option to paste only swaps the x and y axis.
I  
AcidTest : 8/17/2022 10:40 am : link
thought you said it was going to be easy.

Your knowledge of Excel is obviously far beyond mine.

Good luck.
Try flipping  
crackerjack465 : 8/17/2022 10:58 am : link
the source data. Do Data > Sort > first sort Column A by Smallest to Largest and then hit options, change it to left to right, and do the same thing for the row.
RE: I  
Matt M. : 8/17/2022 10:59 am : link
In comment 15783078 AcidTest said:
Quote:
thought you said it was going to be easy.

Your knowledge of Excel is obviously far beyond mine.

Good luck.
It sounds harder than it is. I think a fairly easy solution I should have thought of occurred to me, but it still requires a couple of steps, including cutting and pasting at the end, so I don't love.

You can first sort in ascending order based on the first column, as a normal sort. Then sort again based on the first row, which I don't think I was aware existed as an option. The end result, though, requires me to cut the new last column and paste it as the first column with the row headers.

I was hoping for a formula and/or 1-step solution that doesn't require further interaction with the date (i.e. cut and paste).
RE: Try flipping  
Matt M. : 8/17/2022 11:00 am : link
In comment 15783099 crackerjack465 said:
Quote:
the source data. Do Data > Sort > first sort Column A by Smallest to Largest and then hit options, change it to left to right, and do the same thing for the row.
Ha. I was just outlining that as you suggested it. I didn't recall sorting horizontally was an option until playing around. There is one additional step, but it works.
Sample view  
Matt M. : 8/17/2022 11:06 am : link
A sample of how the data comes to us:

BLANK 16 15 14...0
85 100 99 99 85
84 99 99 98 84
83 99 99 98 84
82 98 98 98 83
.
.
.
0 15 15 14 0

How we need the data:

BLANK 0 1 2 3 ...16
0 0 2 3 5 15
1 2 4 5 7 17
2 3 5 7 9 18
3 5 7 9 10 20
.
.
.
85 85 87 88 90 100
You probably need a helper column.  
robbieballs2003 : 8/17/2022 11:17 am : link
Add a helper column and row. The column should have 1 through 86 or 0 through 85. Then in the row you go from 1 to 17 or 0 through 16.

Once the helper column is there

1. Sort ascending by your helper column
2. Transpose the data
3. Sort by ascending order of your helper row that is now your column
4. Transpose again
5. Remove helper column and row if you want

This is why I like Sheets better. I can put this in a formula once and take care of it.
RE: You probably need a helper column.  
Matt M. : 8/17/2022 11:31 am : link
In comment 15783121 robbieballs2003 said:
Quote:
Add a helper column and row. The column should have 1 through 86 or 0 through 85. Then in the row you go from 1 to 17 or 0 through 16.

Once the helper column is there

1. Sort ascending by your helper column
2. Transpose the data
3. Sort by ascending order of your helper row that is now your column
4. Transpose again
5. Remove helper column and row if you want

This is why I like Sheets better. I can put this in a formula once and take care of it.
The helper columns are built in; they are header rows and columns. I did this initially, but still involved a cut and paste to transpose, as I have not successfully executed the Transpose function. It just returns a single cell with "0", even when creating the function as an array.
Are you decent with Google Sheets?  
robbieballs2003 : 8/17/2022 12:12 pm : link
Is this a one time thing or something that is recurring? If it is a one time thing, just get through it. If it is something that is recurring, I can set up a Google Sheet where all you would do is paste in the table and then copy the new table from a different tab and paste it back into excel.
RE: Are you decent with Google Sheets?  
Matt M. : 8/17/2022 12:27 pm : link
In comment 15783193 robbieballs2003 said:
Quote:
Is this a one time thing or something that is recurring? If it is a one time thing, just get through it. If it is something that is recurring, I can set up a Google Sheet where all you would do is paste in the table and then copy the new table from a different tab and paste it back into excel.
I don't use Google sheets normally. This is recurring, but only a few times a year. It's easy enough to slog through.
Create a new Google Sheet.  
robbieballs2003 : 8/17/2022 1:24 pm : link
In Sheet 1, paste your data.

Create a new tab if there isn't a sheet 2.

In Sheet 2, paste the following in cell A1 ...

=query(transpose(query(query(arrayformula(value(query(transpose(query({Sheet1!A:EC},"Select * where Col2 is not null Order By Col1 asc",1)),"Select * where Col2 is not null Order by Col1 asc",1))),"Select * where Col2 is not null Order by Col1 asc",1),"Select * Offset 1",0)),"Select * Offset 1",0)

This should give you what you want. Let me know if it works.
RE: Create a new Google Sheet.  
Matt M. : 8/17/2022 1:39 pm : link
In comment 15783247 robbieballs2003 said:
Quote:
In Sheet 1, paste your data.

Create a new tab if there isn't a sheet 2.

In Sheet 2, paste the following in cell A1 ...

=query(transpose(query(query(arrayformula(value(query(transpose(query({Sheet1!A:EC},"Select * where Col2 is not null Order By Col1 asc",1)),"Select * where Col2 is not null Order by Col1 asc",1))),"Select * where Col2 is not null Order by Col1 asc",1),"Select * Offset 1",0)),"Select * Offset 1",0)

This should give you what you want. Let me know if it works.
Yes, with one exception. It removed the header rows/column, which we would want
I was guessing that the help columns were the headers.  
robbieballs2003 : 8/17/2022 2:44 pm : link
You said you have help a help column and row. What are they?

Also, are the headers the helper columns? It would be easier if I can see it. I purposely took out the helper row/column.
RE: I was guessing that the help columns were the headers.  
Matt M. : 8/17/2022 2:59 pm : link
In comment 15783306 robbieballs2003 said:
Quote:
You said you have help a help column and row. What are they?

Also, are the headers the helper columns? It would be easier if I can see it. I purposely took out the helper row/column.
Row 1 is the column headers:
A1=BLANK, B1=16, C1 = 15, D1 = 14,...R1 = 0

COLUMN A are the ROW "Headers":
A1=BLANK
A2 = 85
A3 = 84
A4 = 93
.
.
.
A87 = 0
RE: RE: I was guessing that the help columns were the headers.  
Matt M. : 8/17/2022 3:00 pm : link
In comment 15783312 Matt M. said:
Quote:
In comment 15783306 robbieballs2003 said:


Quote:


You said you have help a help column and row. What are they?

Also, are the headers the helper columns? It would be easier if I can see it. I purposely took out the helper row/column.

Row 1 is the column headers:
A1=BLANK, B1=16, C1 = 15, D1 = 14,...R1 = 0

COLUMN A are the ROW "Headers":
A1=BLANK
A2 = 85
A3 = 84
A4 = 93
.
.
.
A87 = 0
The actual data spans B2:R87
Ok, so it is what I thought.  
robbieballs2003 : 8/17/2022 3:44 pm : link
You still need those numbers? I'll get you the formula.
I think this will do it. Double check for me.  
robbieballs2003 : 8/17/2022 3:47 pm : link
=transpose(query(arrayformula(value(query(transpose(query({Sheet2!A:EC},"Select * where Col2 is not null Order By Col1 asc",1)),"Select * where Col2 is not null Order by Col1 asc",1))),"Select * where Col2 is not null Order by Col1 asc",1))
RE: I think this will do it. Double check for me.  
Matt M. : 8/17/2022 4:12 pm : link
In comment 15783380 robbieballs2003 said:
Quote:
=transpose(query(arrayformula(value(query(transpose(query({Sheet2!A:EC},"Select * where Col2 is not null Order By Col1 asc",1)),"Select * where Col2 is not null Order by Col1 asc",1))),"Select * where Col2 is not null Order by Col1 asc",1))
Yes, that works, with a typo. the Sheet2!A:EC reference needed to be changed to Sheet1! to reference the original data.
Correct. Good job  
robbieballs2003 : 8/17/2022 4:21 pm : link
.
RE: Correct. Good job  
Matt M. : 8/17/2022 4:39 pm : link
In comment 15783409 robbieballs2003 said:
Quote:
.
Thank you!
Back to the Corner