Pulling specific columns by transpose two headers

deniztopcu

New Member
Joined
May 9, 2022
Messages
33
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
I want to pull the last 5 quarter data of "Symbol and itemcode" from the table.
Symbol and item code" must be transpose.

Pulling specific columns by transposing two headers

I want to reach an image like the first picture so that I can compare.

2.png


1.png

3.png
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi,

I think it could be super easy to create the desired result by using a Pivot Table as shown below
(Please note that I wrote some random values and symbols since I can't copy from the images. Actually, I suggest using XL2BB for posting data, so helpers can work on the original data by copying it into a worksheet easily).

1672605118183.png


Note: I initially built an array formula for this. However, I realized that you are not using Excel 365, so this will probably not help as I am not sure if all functions I used exist in your Excel version but I already completed the formula. So, although I believe the Pivot Table approach will be much better, here is the formula as well (for Excel 365).

The formula:
Excel Formula:
=LET(
    howManyYears, 5,
    symbols, UNIQUE(Combined_tIFinancials[Symbol]),
    itemCodes, TRANSPOSE(UNIQUE(Combined_tIFinancials[ItemCode])),
    years, TAKE(DROP(Combined_tIFinancials[#Headers],,2),,howManyYears),
    itemHeaders, INDEX(itemCodes,,QUOTIENT(SEQUENCE(1,COLUMNS(years)*COLUMNS(itemCodes))-1,howManyYears)+1),
    yearHeaders, INDEX(years,,MOD(SEQUENCE(1,COLUMNS(years)*COLUMNS(itemCodes))-1,COLUMNS(years))+1),
    totals, SUMIFS(INDIRECT("Combined_tIFinancials[" & yearHeaders & "]"),Combined_tIFinancials[Symbol],symbols,Combined_tIFinancials[ItemCode], itemHeaders),
    dataTable, VSTACK(itemHeaders, yearHeaders, totals),
    symbolColumn, VSTACK("","",symbols),
    result, HSTACK(symbolColumn, dataTable),
result
)
Book17
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1SymbolItemCode2022/92022/62022/32021/122021/92021/6 1A1A1A1A1A1AA1AA1AA1AA1AA1AB1AB1AB1AB1AB1AE1AE1AE1AE1AE
2a1A6288974778102022/92022/62022/32021/122021/92022/92022/62022/32021/122021/92022/92022/62022/32021/122021/92022/92022/62022/32021/122021/9
3a1AA623785245720a6288974778623785245727748851419941746822
4a1AB277488514130b208118985507441459777396532000000
5b1A20811898540c0000063804348750000000000
6c1AA638043487550
7b1AB77396532060
8b1AA507441459770
9a1AE994174682280
Sheet1
Cell Formulas
RangeFormula
J1:AD5J1=LET( howManyYears, 5, symbols, UNIQUE(Combined_tIFinancials[Symbol]), itemCodes, TRANSPOSE(UNIQUE(Combined_tIFinancials[ItemCode])), years, TAKE(DROP(Combined_tIFinancials[#Headers],,2),,howManyYears), itemHeaders, INDEX(itemCodes,,QUOTIENT(SEQUENCE(1,COLUMNS(years)*COLUMNS(itemCodes))-1,howManyYears)+1), yearHeaders, INDEX(years,,MOD(SEQUENCE(1,COLUMNS(years)*COLUMNS(itemCodes))-1,COLUMNS(years))+1), totals, SUMIFS(INDIRECT("Combined_tIFinancials[" & yearHeaders & "]"),Combined_tIFinancials[Symbol],symbols,Combined_tIFinancials[ItemCode], itemHeaders), dataTable, VSTACK(itemHeaders, yearHeaders, totals), symbolColumn, VSTACK("","",symbols), result, HSTACK(symbolColumn, dataTable), result )
Dynamic array formulas.
 
Upvote 0
Formula I am trying to make it compatible with very long Turkish characters. I am still not successful.
I still suggest the Pivot Table approach.

However, if you have chance to use it in Excel 365, then please let me know, so I can convert it to Turkish version for you a bit later today.
 
Upvote 0
Hala Pivot Tablo yaklaşımını öneriyorum.

Ancak, Excel 365'te kullanma şansınız varsa, lütfen bana bildirin, bugün biraz sonra sizin için Türkçe sürüme çevirebilirim.
I don't have access to Office 365.
I get the result by doing this project with some functions (vlookup, hlookup, index...). But what I want is to reach the result in a short way like yours (the query can be on every line) or to reach the result quickly in a way that makes the system least tiring.
I will be glad if you translate it into Turkish.
I don't know how to do it with pivot table. Is it more advantageous than the first one you wrote in terms of system and time?
 
Upvote 0
I don't have access to Office 365.

I believe, it is more advantageous creating a Pivot Table for this question. Besides, the function I sent above is for 365 because of some unsupported functions in 2021 (that's why I mentioned "if you have a chance to use 365" even though I noticed your Excel version on your profile.)

Creating a Pivot Table is not complicated, in fact, it is much easier and it can be used to create complicated reports faster.

Select the range (or the top-left cell in the range since the wizard will auto-select the whole range), and click on Insert->Pivot Table.

1672677138845.png


Select New Worksheet and click OK. A new worksheet will be created and the Pivot Table fields pane will appear on the right side.

1672677218097.png


In the right pane, drag the Symbol field into the Rows section below, ItemCode into the Columns section, and years (2022/9 to 2021/9) into the Values section. Then select "On for Columns Only" option in the Design->Grand Totals dropdown (this will remove the additional row grand totals columns).
.
Screenshot 2023-01-02 at 7.38.34 PM.png


Optionally change the column headers and widths as you wish. And you got the report you want. Please note you'll need to refresh the Pivot Table when you change something in the source data.

If you don't think the Pivot Table solution is the better one than do not hesitate to keep asking for the function solution since helpers still can come up with Excel 2021-compatible formulas. Otherwise, the way you do it with multiple formulas is already an option anyway. By the way, no matter which method you will use, you shouldn't notice any performance issues. Although you won't notice that, the fastest one would be the Pivot Table method.
 
Upvote 0
Solution
It is a great loss for me that I have not used a pivot table before.

After duplicating the symbols, I'll have to refresh (as you pointed out) to get them back.
Apart from that, this is the result I want to see visually.

Excel Work is triggered after a change is made in the cell I specified. It would make my job even easier if it was automatic. But I will try to handle this with a macro embedded in a button.

The information you provided was invaluable. Thank you very much for your time and effort.



1672687717983.png
 
Upvote 0
The information you provided was invaluable. Thank you very much for your time and effort
You’re welcome. Glad to hear it helps.
That would be great if you could mark the post as the solution that helped you to help future readers.

(Birşey değil :) )
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top