Help filtering a table using LET, UNIQUE functions

hcova

New Member
Joined
Jul 29, 2010
Messages
29
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi everyone.
1) I have the following excel table.
The Table es named Table1

1732638506310.png


2) I need to write a Dynamic Array formula to calculate the sum of TOTAL (col K) for each unique Code (Col G).
Something like the following output table

1732638642327.png


During my process to get the above table, I tried a way to get the results, but without the table I needed.
Here my steps I did

3) I applied the following formula in cell B37 and I got the below table

1732638823466.png


1732638881412.png


4) Then I wrote the following formula to get the totals by code

1732639004343.png


to obtain this table

1732639086691.png


5) This table solved my problem, but I could't get the output table that I needed as mentioned in 2).

To get the output table of 2), can someone please help me modify the Dynamic Array formula LET/UNIQUE/LAMBDA indicated in 4)

Thanks a lot any help
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
It will be very helpful if you post your example with the forum's tool named XL2BB.

With Excel 365, try Groupby
 
Upvote 0
Filter Demo.xlsx
ABCDEFGHIJK
1ItemITEM DESCRIPTIONSubItemSubItem DescriptionBasis NumberCodeDESCRIPTION 2QUANTU.P.TOTAL
21Previous buildings1.1410160Container for Office6.007.5045.00
31Previous buildings1.2410160Warehouse Container6.004.9029.40
41Previous buildings1.3410160WC Chemical6.003.2119.28
51Previous buildings1.4410160Container shipping4.007.5930.36
61Previous buildings1.5410160Pre closes50.000.9547.50
71Previous buildings1.6410160Electric y water provision6.008.0448.21
82Pre work2.1410106Rethinking plans1.0015.0015.00
92Pre work2.2410106Drawings and levels1.0026.0026.00
103soil movement3.1410150Masiva digging for improvements932.000.45419.40
113soil movement3.2410150Fundations digging104.220.5254.19
123soil movement3.3410130Improvement stuffings932.000.65605.80
133soil movement3.4410130Geogrilla Stratagrid BX30621.000.0955.89
143soil movement3.5410150Excedent removement1,036.220.56580.28
154Fundations4.1410163Concrete Emplant9.872.1721.42
164Fundations4.2410194Reforce steel A63-42H Fund. and Bars5,934.000.05296.70
174Fundations4.3410163Concrete basement G25102.802.85292.98
184Fundations4.4410151Mold Fundaciones Plac terciad345.000.45155.25
195Slab5.1410194Steel for Reforcement A63-42H0.000.000.00
205Slab5.2410163Concrete G2540.383.14126.79
215Slab5.3410151Wall Mold404.000.62250.48
225Slab5.1Floor raft foundation5.1.1410132Compact seal.305.000.1028.98
235Slab5.1Floor raft foundation5.1.2410132Ripio layer30.500.6218.83
245Slab5.1Floor raft foundation5.1.3410132Grid acma c1921,110.000.0888.80
255Slab5.1Floor raft foundation5.1.4410132polyethylene305.000.0515.25
265Slab5.1Floor raft foundation5.1.5410163Concrete raft fundation G20 12cm305.000.68207.40
276Column for Beams6.1410196Metallic beam1,286.000.11135.95
286Column for Beams6.2410240Base plaque enchap. structural 18mm70.920.4834.04
296Column for Beams6.3410240Acustic Bandage fonodan 204.000.0713.67
307Fire Protection7.1410144Fire Retardant anti termit AF-7000 fire proteccion 70.920.085.32
317Fire Protection7.2410144Bar polyethylene 0,20mm70.920.053.55
328OverSlab8.1410163OverSlab Concrete heavy 50mm70.920.5740.44
33
34
35
36
37Extract Colums before SumCodeTOTAL
3841010615.00
3941010626.00
40410130605.80
4141013055.89
4241013228.98
4341013218.83
4441013288.80
4541013215.25
464101445.32
474101443.55
48410150419.40
4941015054.19
50410150580.28
51410151155.25
52410151250.48
5341016045.00
5441016029.40
5541016019.28
5641016030.36
5741016047.50
5841016048.21
5941016321.42
60410163292.98
61410163126.79
62410163207.40
6341016340.44
64410194296.70
654101940.00
66410196135.95
6741024034.04
6841024013.67
69
70DYNAMIC ARRAY SOLUTION
71Sum using LET & UNIQUECodeTOTAL
7241010641.00
73410130661.69
74410132151.85
754101448.87
764101501,053.88
77410151405.73
78410160219.75
79410163689.03
80410194296.70
81410196135.95
8241024047.71
83
84
85I need this OUTPUT
86
87ItemITEM DESCRIPTIONSubItemSubItem DescriptionBasis NumberCodeDESCRIPTION 2QUANTU.P.TOTAL
88--------------------------------------------------410106------------------------------41.00
89--------------------------------------------------410130------------------------------661.69
90--------------------------------------------------410132------------------------------151.85
91--------------------------------------------------410144------------------------------8.87
92--------------------------------------------------410150------------------------------1,053.88
93--------------------------------------------------410151------------------------------405.73
94--------------------------------------------------410160------------------------------219.75
95--------------------------------------------------410163------------------------------689.03
96--------------------------------------------------410194------------------------------296.70
97--------------------------------------------------410196------------------------------135.95
98--------------------------------------------------410240------------------------------47.71
99
100
Table
Cell Formulas
RangeFormula
B37:C68B37=CHOOSECOLS(VSTACK(Table1[#Headers],SORT(FILTER(Table1,Table1[Code],"NO DATA"),6,1)),6,10)
B71:C82B71=VSTACK(B37:C37,LET( uniqueCodes, UNIQUE(B38:B68),incomeTotal, MAP(uniqueCodes, LAMBDA(code, SUMIFS(C38:C68, B38:B68, code))),HSTACK(uniqueCodes, incomeTotal)))
G88:G98G88=+B72
K88:K98K88=+C72
Dynamic array formulas.
 
Upvote 0
Did you try the suggestion?

Groupby_a.xlsx
AGKLMN
1ACODETOTAL
241016010.004101551,350.00
341016015.00410160175.00
441016020.00410170275.00
541016025.00Total1,800.00
641016030.00
741016035.00
841016040.00
941017045.00
1041017050.00
1141017055.00
1241017060.00
1341017065.00
1441015570.00
15410155250.00
16410155280.00
17410155350.00
18410155400.00
19
2f
Cell Formulas
RangeFormula
M2:N5M2=GROUPBY(Table5[CODE],Table5[TOTAL],SUM)
Dynamic array formulas.
 
Upvote 0
Groupby_a.xlsx
BC
3541010641.00
36410130661.69
37410132151.85
384101448.87
394101501,053.88
40410151405.73
41410160219.75
42410163689.03
43410194296.70
44410196135.95
4541024047.71
46Total3,712.16
47
48
Sheet2
Cell Formulas
RangeFormula
B35:C46B35=GROUPBY(Table6[Code],Table6[TOTAL],SUM)
Dynamic array formulas.
 
Upvote 0
How about
Excel Formula:
=LET(s,REPT("-",10),g,GROUPBY(Table1[Code],Table1[TOTAL],SUM,0,0),r,ROWS(g),VSTACK(Table1[#Headers],HSTACK(EXPAND(s,r,5,s),TAKE(g,,1),EXPAND(s,r,3,s),TAKE(g,,-1))))
or if you don't have groupby yet
Excel Formula:
=LET(s,REPT("-",10),u,UNIQUE(Table1[Code]),c,SUMIFS(Table1[TOTAL],Table1[Code],u),r,ROWS(u),VSTACK(Table1[#Headers],HSTACK(EXPAND(s,r,5,s),u,EXPAND(s,r,3,s),c)))
 
Upvote 0
If you require a report with a Grand Total, Total by Code, and Totals with full descriptions, Excel has a feature that does this.
You do not enter any formulas; it yields three views.

Look at Data | Outline | Subtotal
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,334
Members
452,907
Latest member
Roland Deschain

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