All possible combinations between n columns and then find and multiply the corresponding values for every combination.

icatalin32

New Member
Joined
May 12, 2023
Messages
6
Office Version
  1. 2021
  2. 2016
Platform
  1. Windows
Consider this: i have 3 columns ,each contains n rows with text information (not numbers). For every column this is also a column next to it with the corresponding values (factors) of each text.
What i want to do is :
- bring in another column(pivot,sheet,etc) every combination of those 3 columns of text data but in the same time bring another column to the right with the multiplied values of the corresponding combination on the left column. Say we have "21.male.worker" combination and next to it i want to bring and multiply the corresponding factors (values) like this: 21.male.worker : 0.75x0.12x1.34 or 34.female.doctor : 1.23x4.5x0.23
Is it possible in excel 2016?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
This would be a lot cleaner in 365 - maybe 2021 too.

MrExcelPlayground17.xlsx
ABCDEFGHIJKLM
1Parameter 1Multiplier1Parameter 2Multiplier2Parameter 3Multiplier3Parameter 1Parameter 2Parameter 3Product
2Male0.2Worker1.2210.1MaleWorker210.024
3Female0.3Doctor1.3220.2MaleWorker220.048
4Dog0.4Farmer1.4230.3MaleWorker230.072
5Cat0.5Welder1.5240.4MaleWorker240.096
6ComputerGuy1.6250.5MaleWorker250.12
7Chef1.7MaleDoctor210.026
8MaleDoctor220.052
9MaleDoctor230.078
10MaleDoctor240.104
11MaleDoctor250.13
12MaleDoctor210.026
13MaleFarmer220.056
14MaleFarmer230.084
15MaleFarmer240.112
16MaleFarmer250.14
17MaleFarmer210.028
18MaleFarmer220.056
19MaleWelder230.09
20MaleWelder240.12
21MaleWelder250.15
22MaleWelder210.03
23MaleWelder220.06
24MaleWelder230.09
25MaleComputerGuy240.128
26MaleComputerGuy250.16
27MaleComputerGuy210.032
28MaleComputerGuy220.064
29MaleComputerGuy230.096
30MaleComputerGuy240.128
31MaleChef250.17
32FemaleWorker210.036
33FemaleWorker220.072
34FemaleWorker230.108
35FemaleWorker240.144
36FemaleWorker250.18
37FemaleDoctor210.039
38FemaleDoctor220.078
39FemaleDoctor230.117
40FemaleDoctor240.156
41FemaleDoctor250.195
42FemaleDoctor210.039
43FemaleFarmer220.084
44FemaleFarmer230.126
45FemaleFarmer240.168
46FemaleFarmer250.21
47FemaleFarmer210.042
Sheet7
Cell Formulas
RangeFormula
J2:J121J2=INDEX(Table2[Parameter 1],INT((ROW(INDIRECT("1:"&ROWS(Table2)*ROWS(Table3)*ROWS(Table4)))-1)/(ROWS(Table4)*ROWS(Table3)))+1)
K2:K121K2=INDEX(Table3[Parameter 2],INT((MOD(ROW(INDIRECT("1:"&ROWS(Table2)*ROWS(Table3)*ROWS(Table4)))-1,ROWS(Table4)*ROWS(Table3))+1)/ROWS(Table3))+1)
L2:L121L2=INDEX(Table4[Parameter 3],MOD(ROW(INDIRECT("1:"&ROWS(Table2)*ROWS(Table3)*ROWS(Table4)))-1,ROWS(Table4))+1)
M2:M121M2=INDEX(Table2[Multiplier1],INT((ROW(INDIRECT("1:"&ROWS(Table2)*ROWS(Table3)*ROWS(Table4)))-1)/(ROWS(Table4)*ROWS(Table3)))+1)*INDEX(Table3[Multiplier2],INT((MOD(ROW(INDIRECT("1:"&ROWS(Table2)*ROWS(Table3)*ROWS(Table4)))-1,ROWS(Table4)*ROWS(Table3))+1)/ROWS(Table3))+1)*INDEX(Table4[Multiplier3],MOD(ROW(INDIRECT("1:"&ROWS(Table2)*ROWS(Table3)*ROWS(Table4)))-1,ROWS(Table4))+1)
Dynamic array formulas.
 
Upvote 1
Solution
Wow, wow,wow. You're my lifesaver, thank you very very very much. This is exactly what i needed. Ill check this sunday when i get back home and continue work analysis. The problem is that i really dont know right now how many main columns i might have and of course thei multiplier columns too.
 
Upvote 0
Did u named/defined tables: gender as table2, profession as table3 , and age as table4? What parameters should i change if i want to add more tables (parameters and multipliers)
 
Upvote 0
That is how I named the tables (Excel named them really), naturally you can give the tables better names.

Adding more parameters makes the formulas more complex. I'd more and more want to use 365 for that. But mostly, the "row(indirect" bit has to be the product of rows of all tables. So in this example it's 4x6x5. If you added another table, it would be 4x6x5x?. Then you have to add another layer of MOD and INT functions to get the progression through all of the possible combinations. Adding one more layer would be easy enough. Adding many layers would get more and more out-of-hand. I've done this for as many as 7 or 8 parameters, but it gets incomprehensible.
 
Upvote 0
That is how I named the tables (Excel named them really), naturally you can give the tables better names.

Adding more parameters makes the formulas more complex. I'd more and more want to use 365 for that. But mostly, the "row(indirect" bit has to be the product of rows of all tables. So in this example it's 4x6x5. If you added another table, it would be 4x6x5x?. Then you have to add another layer of MOD and INT functions to get the progression through all of the possible combinations. Adding one more layer would be easy enough. Adding many layers would get more and more out-of-hand. I've done this for as many as 7 or 8 parameters, but it gets incomprehensible.
I see, the problem is there could be even 12-20 tables to define, it depends of how many segments i need in my analysis. And bad news, i have only excel 2016. Why do you say in 365 (the anual fee Excel - no need for versions) it is better?i have at home excel 2021. Does it help more?it could be easier in 2021?
Thousands tx,
Kat.
 
Upvote 0
2021 would be good too. I would use the LET function to make the formula's a little easier to follow. 12-20 tables of any length would have an enormous set of permutations if you wanted to look at them all together. If you had just 3 items in each of 15 tables, you have 14million permutations. More than excel rows can handle.
 
Upvote 0
I checked now and i have 3 situations, each of those require all permutations:
Situation 1 - upto 6 tables (each of max 80 records - some tables way less)
Situation 2 - upto 5 tables (the same max 80 records /table - some tables way less)
Situation 3 - upto 3 tables (each of max 12 rows).
 
Upvote 0
Situation 3, you have up there. It'll work just fine if you add more items in the three tables. Sit 2 is doable, very much depending on how many are in your tables. Sit 1 gets out of hand for this solution unless most of your tables are pretty small.

MrExcelPlayground17.xlsx
ZAAABACADAEAFAG
1SituationTable1Table2Table3Table4Table5Table6Permutations
2110510510802,000,000
3210105580200,000
4280808080803,276,800,000
531212121,728
Sheet7
Cell Formulas
RangeFormula
AG2AG2=AA2*AB2*AC2*AD2*AE2*AF2
AG3:AG4AG3=AA3*AB3*AC3*AD3*AE3
AG5AG5=AA5*AB5*AC5
 
Upvote 0
Now i see. Bad news. I'll stick with situations 2 and 3 and put aside situation 1 for now,at least on ms excel. Ill try to adapt what you provided for situation2 (max 5 tables, max 80 records, only 2 tables could reach 80 records, the other 3 at max 15-30 records each).
Thank you again very very much.
 
Upvote 0

Forum statistics

Threads
1,215,438
Messages
6,124,873
Members
449,192
Latest member
MoonDancer

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