generate table based on values from another table

ajith

Board Regular
Joined
Nov 21, 2012
Messages
215
Office Version
  1. 2016
Platform
  1. Windows
Hello all,
Pls help me to generate the table of orders of a particular item using excel formula based on the data available in another table (A or B). The items in the table generated (C,D,E or F) along with its country should get filled without any empty rows. In the attached example table A and B are data table and C, D, E and F are the tables for the result. The result table should be in such a way that whenever we change the item ordered item the result table gets generated without any interference. Thanks in advance.

Order.xlsx
ABCDEFGHIJKLMNO
1CD
2ordersAppleOrange
3AJanuaryOrdersJanuaryOrders
4Country1st week2nd week3rd weekCountry1st weekCountry2nd week
5USAppleOrangeJack
6EnglandAppleGrapesApple
7JanuaryMexicoMangoAppleGrapes
8SpainAppleGrapesPlum
9JapanOrangeOrangeMango
10NorwayOrangeAppleGrapes
11SwedenAppleOrangePlum
12EF
13BMangoPlum
14SpainAppleOrangePlumFebruaryOrdersFebruaryOrders
15SwedenMangoAppleOrangeCountry1st weekCountry3rd week
16MexicoOrangeAppleMango
17FebruaryNorwayAppleGrapesJack
18JapanOrangeAppleJack
19EnglandMangoOrangeApple
20USMangoGrapesPlum
21
22
23
Sheet1
 
Last edited:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
The solution below uses some unpivot code I had so that I could filter the unpivoted data based on your two inputs of fruit and week. Also, you need to repeat the column headers in table B for this to work.

xxx.xlsx
ABCDEFGHIJKLMN
1CD
2ordersAppleOrange
3AJanuaryOrdersJanuaryOrders
4Country1st week2nd week3rd weekCountry1st weekCountry2nd week
5USAppleOrangeJackUSUS
6EnglandAppleGrapesAppleEnglandJapan
7JanuaryMexicoMangoAppleGrapesSpainSweden
8SpainAppleGrapesPlumSweden
9JapanOrangeOrangeMango
10NorwayOrangeAppleGrapes
11SwedenAppleOrangePlum
12EF
13BCountry1st week2nd week3rd weekMangoPlum
14SpainAppleOrangePlumFebruaryOrdersFebruaryOrders
15SwedenMangoAppleOrangeCountry1st weekCountry3rd week
16MexicoOrangeAppleMangoSwedenSpain
17FebruaryNorwayAppleGrapesJackEnglandUS
18JapanOrangeAppleJackUS
19EnglandMangoOrangeApple
20USMangoGrapesPlum
Sheet2
Cell Formulas
RangeFormula
I5:I8,M5:M7I5=LET(range,$C$4:$F$11, fruit,I2, week,J4, r,ROWS(range)-1, c,COLUMNS(range)-1, rowheads,OFFSET(range,1,0,r,1), colheads,OFFSET(range,0,1,1,c), data,OFFSET(range,1,1,r,c), tot,SEQUENCE(r*c), firstcol,INDEX(rowheads,IF(MOD(tot,r)=0,r,MOD(tot,r)),SEQUENCE(,COLUMNS(rowheads))), secondcol,INDEX(colheads,1,ROUNDUP(tot/r,0)), thirdcol,INDEX(data,IF(MOD(tot,r)=0,r,MOD(tot,r)),ROUNDUP(tot/r,0)), ss,SEQUENCE((r*c)+1,,0,1), result,CHOOSE({1,2,3},IF(ss=0,"ROW",INDEX(firstcol,ss,1)),IF(ss=0,"COL",INDEX(secondcol,ss,1)),IF(ss=0,"DATA",INDEX(thirdcol,ss,1))), TAKE(FILTER(result,(CHOOSECOLS(result,3)=fruit)*(CHOOSECOLS(result,2)=week),"None"),,1))
I16:I18,M16:M17I16=LET(range,$C$13:$F$20, fruit,I13, week,J15, r,ROWS(range)-1, c,COLUMNS(range)-1, rowheads,OFFSET(range,1,0,r,1), colheads,OFFSET(range,0,1,1,c), data,OFFSET(range,1,1,r,c), tot,SEQUENCE(r*c), firstcol,INDEX(rowheads,IF(MOD(tot,r)=0,r,MOD(tot,r)),SEQUENCE(,COLUMNS(rowheads))), secondcol,INDEX(colheads,1,ROUNDUP(tot/r,0)), thirdcol,INDEX(data,IF(MOD(tot,r)=0,r,MOD(tot,r)),ROUNDUP(tot/r,0)), ss,SEQUENCE((r*c)+1,,0,1), result,CHOOSE({1,2,3},IF(ss=0,"ROW",INDEX(firstcol,ss,1)),IF(ss=0,"COL",INDEX(secondcol,ss,1)),IF(ss=0,"DATA",INDEX(thirdcol,ss,1))), TAKE(FILTER(result,(CHOOSECOLS(result,3)=fruit)*(CHOOSECOLS(result,2)=week),"None"),,1))
Dynamic array formulas.
 
Upvote 0
@wjhladik The OP's profile shows 2016 & so does not have a lot of those functions.
 
Upvote 0
@wjhladik The OP's profile shows 2016 & so does not have a lot of those functions.
Sorry, didn't notice that. I'm of the mindset that anyone can use excel online (for free basically) and get access to most 365 level formulas. Just depends if their situation warrants it... e.g. business allows and simple upload of data does the trick. Oh well, maybe others can benefit from the embedded unpivot formula.
 
Upvote 0
I'm of the mindset that anyone can use excel online (for free basically)
That may be so, but please post solutions that will work for the OP's version(if listed).
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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