APIVOT

=APIVOT(a,rw,cl,vl,vf)

a
array
rw
integer, column index that holds corespondent PT row values
cl
integer, column index that holds corespondent PT column values
vl
integer, integer, column index that holds corespondent PT values
vf
integer, value field, 0 or ignored for sum, 1 for count, 2 for min, 3 for max

array pivot, reproduces basic functionality of Pivot Table, with a single cell lambda, for any array, regular, dynamic, table, no refresh needed

Xlambda

Well-known Member
Joined
Mar 8, 2021
Messages
860
Office Version
  1. 365
Platform
  1. Windows
APIVOT array pivot, reproduces basic functionality of Pivot Table, with a single cell lambda, for any array, regular, dynamic, table. calls AAGGREGATE , APPEND2V , APPEND2H
Basic functionality means: as in PT interface we can select rows values, column values, values, value fields, only sum, count, min and max
- disadvantages: was not designed to compete with mighty PT, does not have grouping functionality as PT does, though, could be added but the formulas can get discouraging huge.
- advantages: no table format needed, no refresh needed, so if we filter a large table for some complex criteria in a simple dynamic array, this lambda can be handy.
Other functions on minisheet ASELECT
Note: Sample data, courtesy of Mike Girvin ExcelIsFun
Excel Formula:
=LAMBDA(a,rw,cl,vl,vf,
    LET(g,"Grand Total",fn,IF(vf=0,0,vf),q,SEQUENCE(,COLUMNS(a)),c,INDEX(a,,cl),r,INDEX(a,,rw),v,INDEX(a,,vl),uc,SORT(UNIQUE(c)),ur,SORT(UNIQUE(r)),tc,TRANSPOSE(uc),f,IF(AND(ISNUMBER(v)),fn,1),
       ar,SWITCH(f,0,SUMIFS(v,r,ur,c,tc),2,MINIFS(v,r,ur,c,tc),3,MAXIFS(v,r,ur,c,tc),1,COUNTIFS(r,ur,c,tc)),fg,SWITCH(f,2,0,3,1,4,7,5),
       rc,AAGGREGATE(ar,fg,),br,TRANSPOSE(AAGGREGATE(TRANSPOSE(ar),fg,)),
       w,ROWS(ar)+1,u,COLUMNS(ar)+2,sr,SEQUENCE(w),sc,SEQUENCE(,u)-1,lc,IF(sr=w,g,INDEX(ur,sr)),tr,SWITCH(sc,0,"("&rw&"\"&cl&")"&" "&vl&" vf="&fn,u-1,g,INDEX(tc,sc)),
       aa,APPEND2V(APPEND2H(ar,rc,),br,),ab,IF(aa="",SWITCH(f,2,MIN(br,rc),3,MAX(br,rc),SUM(rc)),aa),ac,APPEND2V(tr,APPEND2H(lc,ab,),),
       IFS(ISNA(XMATCH(fn,{0,1,2,3})),"check function nr.",NOT(AND(ISNUMBER(XMATCH(CHOOSE({1,2,3},rw,cl,vl),q)))),"check selection",TRUE,ac)
    )
)
LAMBDA 7.0.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAA
1sample data, courtesy of Mike GirvinExcelIsFun=APIVOT(Rev,2,4,6,)vf=0sumSum of Net RevenueColumn Labels
2DateSales RepUnitsProductRegionNet Revenue(2\4) 6 vf=0Crested BeautMajestic BeautQuadSunsetYanakiGrand TotalRow LabelsCrested BeautMajestic BeautQuadSunsetYanakiGrand Total
301-01-20Tynia Malone500QuadMidWest12560.88Chantel Mims7659.578379.3328169.7129746.5913486.9687442.16Chantel Mims7659.578379.3328169.7129746.61348787442.16
401-01-20Kiki Sho38YanakiMidWest902.79Hien Pham7785.007809.9422079.839952.8819538.6867166.33Hien Pham77857809.9422079.839952.8819538.767166.33
501-01-20Hien Pham500YanakiMidWest8035.63Janis Figueroa161.701104.4218189.425683.153039.7528178.44Janis Figueroa161.71104.4218189.425683.153039.7528178.44
601-01-20Chantel Mims500YanakiWest8035.63Kiki Sho9137.046161.932809.605981.8010598.5734688.94Kiki Sho9137.046161.932809.65981.810598.634688.94
701-01-20Tynia Malone39QuadEast1481.47Tynia Malone948.47339.5038904.912434.6314517.6357145.14Tynia Malone948.47339.538904.912434.6314517.657145.14
801-01-20Kiki Sho48SunsetMidWest934.2Grand Total25691.7823795.12110153.553799.0561181.59274621.01Grand Total25691.7823795.12110153.4753799.161181.6274621.01
901-01-20Hien Pham13QuadCanada580.97
1002-01-20Tynia Malone27YanakiNorthWest641.45=APIVOT(Rev,2,4,6,1)vf=1count
1102-01-20Hien Pham13SunsetMidWest337.35(2\4) 6 vf=1Crested BeautMajestic BeautQuadSunsetYanakiGrand Total
1202-01-20Chantel Mims36SunsetMidWest732.87Chantel Mims7567631
1302-01-20Tynia Malone44QuadSouth1596.61Hien Pham2456724
1403-01-20Hien Pham100Crested BeautMidWest1816.5Janis Figueroa1242110
1503-01-20Chantel Mims7YanakiMexico188.65Kiki Sho5234519
1603-01-20Hien Pham5YanakiMexico139.75Tynia Malone1177319
1703-01-20Chantel Mims37QuadMexico1374.05Grand Total1614252622103
1803-01-20Janis Figueroa525QuadMexico13188.92
1903-01-20Chantel Mims450SunsetNorthWest6714.56=APIVOT(Rev,2,4,6,2)vf=2minMin of Net RevenueColumn Labels
2004-01-20Hien Pham45SunsetCanada916.09(2\4) 6 vf=2Crested BeautMajestic BeautQuadSunsetYanakiGrand TotalRow LabelsCrested BeautMajestic BeautQuadSunsetYanakiGrand Total
2104-01-20Tynia Malone3SunsetWest74.85Chantel Mims215.6209.7312.83639.6726.9526.95Chantel Mims215.6209.7312.83639.6726.9526.95
2204-01-20Chantel Mims48Crested BeautWest934.2Hien Pham1816.533.95218.4524.9555.924.95Hien Pham1816.533.95218.4524.9555.924.95
2304-01-20Chantel Mims100Crested BeautMidWest1746.5Janis Figueroa161.734.9585.38174.653039.7534.95Janis Figueroa161.734.9585.38174.653039.7534.95
2404-01-20Hien Pham2YanakiSouth55.9Kiki Sho249.5305.55305.83311.457.957.9Kiki Sho249.5305.55305.83311.457.957.9
2504-01-20Kiki Sho25QuadMexico907.16Tynia Malone948.47339.5298.8374.85641.4574.85Tynia Malone948.47339.5298.8374.85641.4574.85
2604-01-20Chantel Mims8Crested BeautSouth215.6Grand Total161.733.9585.3824.9526.9524.95Grand Total161.733.9585.3824.9526.9524.95
2704-01-20Kiki Sho34Crested BeautMidWest778.86
2804-01-20Chantel Mims275YanakiWest4419.59=APIVOT(Rev,2,4,6,3)vf=3max
2905-01-20Chantel Mims200QuadEast5976.6(2\4) 6 vf=3Crested BeautMajestic BeautQuadSunsetYanakiGrand Total
3005-01-20Hien Pham600YanakiEast9297.75Chantel Mims2724.756291.2514114.387531.788035.6314114.38
3105-01-20Janis Figueroa36Majestic BeautMidWest1069.47Hien Pham5968.56291.2513816.967574.199297.7513816.96
3205-01-20Chantel Mims28QuadMidWest1039.82Janis Figueroa161.71069.4713188.925508.53039.7513188.92
3305-01-20Kiki Sho525YanakiMidWest8437.41Kiki Sho5021.195856.381596.614191.258437.418437.41
3405-01-20Chantel Mims6Majestic BeautCanada209.7Tynia Malone948.47339.512560.88934.27633.8412560.88
3505-01-20Kiki Sho9Majestic BeautWest305.55Grand Total5968.56291.2514114.387574.199297.7514114.38
3605-01-20Hien Pham550QuadMidWest13816.96
3706-01-20Kiki Sho250SunsetEast4191.25=APIVOT(Rev,2,4,3,)Sum of Units2Column Labels
3806-01-20Tynia Malone7QuadCanada298.83(2\4) 3 vf=0Crested BeautMajestic BeautQuadSunsetYanakiGrand TotalRow LabelsCrested BeautMajestic BeautQuadSunsetYanakiGrand Total
3906-01-20Chantel Mims150Crested BeautCanada2724.75Chantel Mims401321102220058174566Chantel Mims401321102220058174566
4006-01-20Tynia Malone43Crested BeautMidWest948.47Hien Pham50029885666011893503Hien Pham50029885666011893503
4107-01-20Kiki Sho21SunsetNorthWest544.95Janis Figueroa6376774071501277Janis Figueroa6376774071501277
4207-01-20Hien Pham13QuadWest554.97Kiki Sho560309763316141890Kiki Sho560309763316141890
4307-01-20Tynia Malone24SunsetWest529.38Tynia Malone431014711118772512Tynia Malone431014711118772512
4407-01-20Tynia Malone15SunsetMexico389.25Grand Total151097541023514364713748Grand Total151097541023514364713748
4508-01-20Kiki Sho2YanakiMidWest57.9
4608-01-20Tynia Malone4SunsetNorthWest99.8=APIVOT(Rev,4,5,3,)Sum of UnitsColumn Labels
4708-01-20Kiki Sho42YanakiEast997.82(4\5) 3 vf=0CanadaEastMexicoMidWestNorthWestSouthWestGrand TotalRow LabelsCanadaEastMexicoMidWestNorthWestSouthWestGrand Total
4808-01-20Chantel Mims500SunsetEast7460.63Crested Beaut1501694112830408891510Crested Beaut150169411283408891510
4908-01-20Hien Pham38Majestic BeautEast1161.19Majestic Beaut15381033657259260975Majestic Beaut15381033657259260975
5008-01-20Tynia Malone48SunsetMexico934.2Quad170241638107827512554454102Quad170241638107827512554454102
5108-01-20Chantel Mims29SunsetSouth639.67Sunset55802664497482299853514Sunset55802664497482299853514
5209-01-20Hien Pham45YanakiCanada1069.09Yanaki458242110655393777763647Yanaki458242110655393777763647
5309-01-20Tynia Malone10SunsetCanada239.5Grand Total43520741744325913532328255513748Grand Total43520741744325913532328255513748
5409-01-20Kiki Sho7QuadWest305.83
5509-01-20Janis Figueroa6Crested BeautMidWest161.7=APIVOT(Rev,4,5,6,)Sum of Net RevenueColumn Labels
5609-01-20Chantel Mims1YanakiWest26.95(4\5) 6 vf=0CanadaEastMexicoMidWestNorthWestSouthWestGrand TotalRow LabelsCanadaEastMexicoMidWestNorthWestSouthWestGrand Total
5709-01-20Tynia Malone475YanakiNorthWest7633.84Crested Beaut2724.753153.696338.655452.0306184.11838.5625691.78Crested Beaut2724.753153.696338.655452.036184.11838.5625691.78
5809-01-20Chantel Mims33Crested BeautMexico699.85Majestic Beaut524.251161.19339.56925.851598.786614.86630.7523795.12Majestic Beaut524.251161.19339.56925.851598.786614.86630.7523795.12
5909-01-20Janis Figueroa75QuadCanada2457.56Quad5794.927543.4517379.5727417.666908.4833327.4711781.9110153.47Quad5794.927543.4517379.627417.666908.4833327.511781.9110153.47
6009-01-20Chantel Mims50Majestic BeautNorthWest1348.13Sunset1155.5912777.589997.947512.927533.96639.6714181.453799.05Sunset1155.5912777.69997.947512.927533.96639.6714181.453799.05
6110-01-20Janis Figueroa7SunsetNorthWest174.65Yanaki1069.0914095.56579.9517433.739222.856298.2412482.261181.59Yanaki1069.0914095.6579.9517433.739222.856298.2412482.261181.59
6210-01-20Chantel Mims575QuadSouth14114.38Grand Total11268.638731.4734635.6164742.1925264.0753064.2846914.8274621.01Grand Total11268.638731.534635.664742.1925264.0753064.346914.8274621.01
6310-01-20Janis Figueroa150YanakiEast3039.75
6411-01-20Kiki Sho300Majestic BeautMidWest5856.38
6511-01-20Janis Figueroa400SunsetMidWest5508.5dynamic APIVOT interface usingASELECT(proves that APIVOT works with dynamic arrays,no need of tables, no refresh)
6611-01-20Chantel Mims32YanakiEast760.24date 1date 2row startrow end
6711-01-20Chantel Mims28Crested BeautMexico617.6103-01-2005-01-201227
6811-01-20Kiki Sho41Crested BeautWest904.36=APIVOT(H70#,1,2,3,)
6911-01-20Chantel Mims425SunsetWest5852.78=ASELECT(Rev,J67,K67,,,{2,4,6})(1\2) 3 vf=0Crested BeautQuadSunsetYanakiGrand Total
7012-01-20Chantel Mims6Majestic BeautNorthWest215.7Hien PhamCrested Beaut1816.5Chantel Mims2896.37350.656714.564608.2421569.75
7112-01-20Hien Pham1Majestic BeautWest33.95Chantel MimsYanaki188.65Hien Pham1816.50916.09195.652928.24
7212-01-20Chantel Mims40SunsetEast814.3Hien PhamYanaki139.75Janis Figueroa013188.920013188.92
7312-01-20Hien Pham28YanakiNorthWest689.01Chantel MimsQuad1374.05Kiki Sho778.86907.16001686.02
7412-01-20Chantel Mims34Crested BeautEast721.06Janis FigueroaQuad13188.92Tynia Malone0074.85074.85
7512-01-20Hien Pham550SunsetMexico7574.19Chantel MimsSunset6714.56Grand Total5491.6621446.737705.54803.8939447.78
7613-01-20Chantel Mims7QuadMexico312.83Hien PhamSunset916.09
7713-01-20Hien Pham9YanakiMexico251.55Tynia MaloneSunset74.85
7813-01-20Kiki Sho10Crested BeautEast249.5Chantel MimsCrested Beaut934.2top left corner cell format
7913-01-20Chantel Mims250Majestic BeautSouth6291.25Chantel MimsCrested Beaut1746.5(rows\columns) values value field=
8013-01-20Hien Pham9Majestic BeautSouth323.55Hien PhamYanaki55.9kept it in this shape because if we pivot regular arrays, they do not have headers
8113-01-20Tynia Malone375YanakiSouth6242.34Kiki ShoQuad907.16
8214-01-20Tynia Malone425QuadSouth10921.12Chantel MimsCrested Beaut215.6
8314-01-20Hien Pham275QuadNorthWest6908.48Kiki ShoCrested Beaut778.86
8414-01-20Kiki Sho44QuadMexico1596.61Chantel MimsYanaki4419.59
8514-01-20Janis Figueroa1Majestic BeautNorthWest34.95Chantel MimsQuad5976.6
8614-01-20Kiki Sho125Crested BeautEast2183.13
APIVOT post
Cell Formulas
RangeFormula
H1,H69,L68,H55,H46,H37,H28,H19,H10H1=FORMULATEXT(H2)
H2:N8H2=APIVOT(Rev,2,4,6,)
H11:N17H11=APIVOT(Rev,2,4,6,1)
H20:N26H20=APIVOT(Rev,2,4,6,2)
H29:N35H29=APIVOT(Rev,2,4,6,3)
H38:N44H38=APIVOT(Rev,2,4,3,)
H47:P53H47=APIVOT(Rev,4,5,3,)
H56:P62H56=APIVOT(Rev,4,5,6,)
J67J67=XMATCH(H67,Rev[Date],1)
K67K67=XMATCH(I67,Rev[Date],-1)
L69:Q75L69=APIVOT(H70#,1,2,3,)
H70:J85H70=ASELECT(Rev,J67,K67,,,{2,4,6})
Dynamic array formulas.
 
Upvote 0
Inspired by MrExcel today's YT (16Mar2022) : Sorted Summary Report WIth Totals In Excel Without A Pivot Table - 2487
2 functions to reproduce Pivot Tables functionality:
1st, PIVOT, a lambda helper function, does the calculations corresponding to the "inner" array calculations and can be used anywhere as stand-alone function or inside other functions constructions, can work with ANY function, also can reproduce functionality of all ...IFS functions, without the range argument limitations of ...IFS functions.
2nd, APIVOT, Array Pivot, completes PT layout "cosmetics", does rows/columns labels and grand totals calculations.

PIVOT(r,c,v,fn) Lambda Helper Pivot Table function
r
: rows column of an array or table.
c: columns column of an array or table
v: values column of an array or table
fn: lambda helper function argument: LAMBDA(x,function(x))
Note: If fn returns more than a single value, those values will be text joined.
Excel Formula:
=LAMBDA(r,c,v,fn,
    LET(
        d, ",",ur, SORT(UNIQUE(r)),uc, SORT(UNIQUE(c)),
        w, ROWS(ur),l, ROWS(uc),
        MAKEARRAY(w,l,LAMBDA(y,x,
                LET(
                    a, INDEX(ur, y),b, INDEX(uc, x),
                    i, IF((a = r) * (b = c), v, ""),f, FILTER(i, i <> ""),
                    fx, IF(ISERR(SUM(f)), "", IFERROR(fn(f), "")),
                    IF(COUNTA(fx) > 1, TEXTJOIN(d, , fx), fx))))
    )
)
APIVOT(r,c,v,fn,[p],[tc],[tr]) completes the pivot table layout "cosmetics" with labels and grand totals calculations. Calls PIVOT
r,c,v,fn: same argument as previous function
[p]: pivot table name label, if omitted "PT"
[tc]: trailing column label, if omitted "GT"
[tr]: trailing row label, if omitted "GT"
Excel Formula:
=LAMBDA(r, c, v, fn, [p], [tr], [tc],
    LET(
        ur, SORT(UNIQUE(r)),
        uc, TOROW(SORT(UNIQUE(c))),
        x, VSTACK(IF(p = "", "PT", p), ur, IF(tc = "", "GT", tc)),
        y, VSTACK(uc, PIVOT(r, c, v, fn), PIVOT(, c, v, fn)),
        z, VSTACK(IF(tr = "", "GT", tr), PIVOT(r, , v, fn), PIVOT(, , v, fn)),
        a, HSTACK(x, y, z),
        FILTER(FILTER(a, TAKE(a, 1) <> 0), TAKE(a, , 1) <> 0)
    )
)
LHPIVOT.xlsx
ABCDEFGHIJKLMNOPQRSTUVW
1sample array (not table)r,"Product" clm,c,omitted,v,"Sales" clm, fn, sum/count
2TeamNameProductSalesc,omitted => only grand totals will be displayed, similar to sumifs/countifs functionality
3RedAmandaApple559=APIVOT(D3:D28,,E3:E28,LAMBDA(x,SUM(x)),"Product","Sales","Total")
4RedThiagoKiwi40↓↓↓↓=APIVOT(D3:D28,,E3:E28,LAMBDA(x,COUNT(x)),"Product","Count","Total")
5RedCarolLemon808ProductSales=SUMIFS(E3:E28,D3:D28,G6:G11)ProductCount=COUNTIFS(D3:D28,O6:O11)
6BlueDanielLime200Apple36113611Apple66
7RedDanielaApple903Kiwi4040Kiwi11
8BlueEduardoOrange656Lemon31083108Lemon66
9RedGabrielLemon404Lime25852585Lime66
10BlueHelenaLime526Orange28012801Orange66
11BlueBernandoOrange291Quince578578Quince11
12RedIsabellaApple559Total12723Total26
13BlueJuao PedroOrange485
14RedJoseLemon354r,"Product" clm, c,"Team" clm, v,"Sales" clm, fn,sum, p,Prd/Team, tc,tr,omitted
15BlueStephanieLime270=APIVOT(D3:D28,B3:B28,E3:E28,LAMBDA(x,SUM(x)),"Prd/Team")
16RedThiagoApple693Prd/TeamBlueRedGT
17RedAmandaOrange235Apple89727143611
18BlueBernandoLemon610Kiwi4040
19RedCarolLime619Lemon154215663108
20BlueDanielApple612Lime99615892585
21RedDanielaOrange596Orange143213692801
22BlueEduardoLemon448Quince578578
23RedGabrielLime851GT5445727812723
24BlueHelenaApple285
25RedIsabellaOrange538r,"Name" clm, c,"Product" clm, v,"Sales" clm, fn,average, p,tc,tr,omitted
26BlueJuao PedroLemon484=APIVOT(C3:C28,D3:D28,E3:E28,LAMBDA(x,AVERAGE(x)))
27RedJoseLime119PTAppleKiwiLemonLimeOrangeQuinceGT
28BlueStephanieQuince578Amanda559235397
29Bernando610291450.5
30Carol808619713.5
31Daniel612200406
32Daniela903596749.5
33Eduardo448656552
34Gabriel404851627.5
35Helena285526405.5
36Isabella559538548.5
37Jose354119236.5
38Juao Pedro484485484.5
39Stephanie270578424
40Thiago69340366.5
41GT601.840518430.8466.8578489.3
42
PIV 1
Cell Formulas
RangeFormula
G3G3=FORMULATEXT(G5)
O4,G26,G15,R5,J5O4=FORMULATEXT(O5)
G5:H12G5=APIVOT(D3:D28,,E3:E28,LAMBDA(x,SUM(x)),"Product","Sales","Total")
O5:P12O5=APIVOT(D3:D28,,E3:E28,LAMBDA(x,COUNT(x)),"Product","Count","Total")
J6:J11J6=SUMIFS(E3:E28,D3:D28,G6:G11)
R6:R11R6=COUNTIFS(D3:D28,O6:O11)
G16:J23G16=APIVOT(D3:D28,B3:B28,E3:E28,LAMBDA(x,SUM(x)),"Prd/Team")
G27:N41G27=APIVOT(C3:C28,D3:D28,E3:E28,LAMBDA(x,AVERAGE(x)))
Dynamic array formulas.
 
Versatility of PIVOT/APIVOT.
Omitting r or c or both arguments triggers PIVOT function to calculate Grand Totals row/column and Grand Total general.
That functionality is used by APIVOT to attach PT Grand Total elements
......y, VSTACK(uc, PIVOT(r, c, v, fn), PIVOT(, c, v, fn)), z, VSTACK(IF(tr = "", "GT", tr), PIVOT(r, , v, fn), PIVOT(, , v, fn)),.....
LHPIVOT.xlsx
ABCDEFGHIJKLMNOPQRST
1sample array (not table)Functionality PIVOT/APIVOT when r or c or both arguments are omitted
2TeamNameProductSales1. c,omitted
3RedAmandaApple559r,"Name" clm, c,omitted, v,"Sales" clm, fn,sum
4RedThiagoKiwi40=PIVOT(C3:C28,,E3:E28,LAMBDA(x,SUM(x)))
5RedCarolLemon808↓↓↓↓=APIVOT(C3:C28,,E3:E28,LAMBDA(x,SUM(x)))
6BlueDanielLime200↓↓↓↓PTGT
7RedDanielaApple903794Amanda7942. r,omitted
8BlueEduardoOrange656901Bernando901r,omitted, c,"Product" clm, v,"Sales" clm, fn,sum
9RedGabrielLemon4041427Carol1427=PIVOT(,D3:D28,E3:E28,LAMBDA(x,SUM(x)))
10BlueHelenaLime526812Daniel812361140310825852801578
11BlueBernandoOrange2911499Daniela1499
12RedIsabellaApple5591104Eduardo1104=APIVOT(,D3:D28,E3:E28,LAMBDA(x,SUM(x)))
13BlueJuao PedroOrange4851255Gabriel1255PTAppleKiwiLemonLimeOrangeQuinceGT
14RedJoseLemon354811Helena811GT36114031082585280157812723
15BlueStephanieLime2701097Isabella1097
16RedThiagoApple693473Jose4733. r,c, omitted
17RedAmandaOrange235969Juao Pedro969=PIVOT(,,E3:E28,LAMBDA(x,SUM(x)))
18BlueBernandoLemon610848Stephanie84812723
19RedCarolLime619733Thiago733
20BlueDanielApple612GT12723=APIVOT(,,E3:E28,LAMBDA(x,SUM(x)))
21RedDanielaOrange596PTGT
22BlueEduardoLemon448GT12723
23RedGabrielLime851
24BlueHelenaApple285Actually this versatility is used on purpose by the design of APIVOT to calculate Grand Totals row/column/general
25RedIsabellaOrange538and attach them to the final PT layout.
26BlueJuao PedroLemon484
27RedJoseLime119r,"Name" clm, c,"Product" clm, v,"Sales" clm, fn,sum, p,tc,tr,omitted
28BlueStephanieQuince578=APIVOT(C3:C28,D3:D28,E3:E28,LAMBDA(x,SUM(x)))
29PTAppleKiwiLemonLimeOrangeQuinceGT
30Amanda559235794
31Bernando610291901
32Carol8086191427
33Daniel612200812
34Daniela9035961499
35Eduardo4486561104
36Gabriel4048511255
37Helena285526811
38Isabella5595381097
39Jose354119473
40Juao Pedro484485969
41Stephanie270578848
42Thiago69340733
43GT36114031082585280157812723
44
PIV 2
Cell Formulas
RangeFormula
G4G4=FORMULATEXT(G7)
I5,G28,L20,M17,L12,M9I5=FORMULATEXT(I6)
I6:J20I6=APIVOT(C3:C28,,E3:E28,LAMBDA(x,SUM(x)))
G7:G19G7=PIVOT(C3:C28,,E3:E28,LAMBDA(x,SUM(x)))
M10:R10M10=PIVOT(,D3:D28,E3:E28,LAMBDA(x,SUM(x)))
L13:S14L13=APIVOT(,D3:D28,E3:E28,LAMBDA(x,SUM(x)))
M18M18=PIVOT(,,E3:E28,LAMBDA(x,SUM(x)))
L21:M22L21=APIVOT(,,E3:E28,LAMBDA(x,SUM(x)))
G29:N43G29=APIVOT(C3:C28,D3:D28,E3:E28,LAMBDA(x,SUM(x)))
Dynamic array formulas.
 
Functionality PIVOT/APIVOT when values clm "v" arguments is omitted.
LHPIVOT.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAE
1sample array (not table)Functionality PIVOT/APIVOT when v arguments is omitted
2TeamNameProductSales
3RedAmandaApple559=PIVOT(C3:C28,D3:D28,,LAMBDA(x,SUM(x)))
4RedThiagoKiwi40↓↓=APIVOT(C3:C28,D3:D28,,LAMBDA(x,SUM(x)))
5RedCarolLemon808↓↓PTAppleKiwiLemonLimeOrangeQuinceGT
6BlueDanielLime20000Amanda000
7RedDanielaApple90300Bernando000
8BlueEduardoOrange65600Carol000
9RedGabrielLemon40400Daniel000
10BlueHelenaLime52600Daniela000
11BlueBernandoOrange29100Eduardo000
12RedIsabellaApple55900Gabriel000
13BlueJuao PedroOrange48500Helena000
14RedJoseLemon35400Isabella000
15BlueStephanieLime27000Jose000
16RedThiagoApple69300Juao Pedro000
17RedAmandaOrange23500Stephanie000
18BlueBernandoLemon61000Thiago000
19RedCarolLime619GT000000
20BlueDanielApple612
21RedDanielaOrange596Makes sense when values argument "v" is omitted to get a bunch of 0'sCompared with PT, this is how PT will look when no values clm is selected
22BlueEduardoLemon448that with our functions, at least, can be counted.
23RedGabrielLime851=APIVOT(C3:C28,D3:D28,,LAMBDA(x,COUNT(x)))Column Labels
24BlueHelenaApple285PTAppleKiwiLemonLimeOrangeQuinceGTRow LabelsAppleKiwiLemonLimeOrangeQuinceGrand Total
25RedIsabellaOrange538Amanda112Amanda
26BlueJuao PedroLemon484Bernando112Bernando
27RedJoseLime119Carol112Carol
28BlueStephanieQuince578Daniel112Daniel
29Daniela112Daniela
30Eduardo112Eduardo
31Gabriel112Gabriel
32Helena112Helena
33Isabella112Isabella
34Jose112Jose
35Juao Pedro112Juao Pedro
36Stephanie112Stephanie
37Thiago112Thiago
38GT616661Grand Total
39
40Note: When "v" is omitted notice that we have no value for Grand Total general(bottom right corner)
41To get the GT general for count we have to choose a column as values "v", if "v" clm has only text values will use as "fn" COUNTA,
42if "v" has numeric values we can use as fn both COUNT or COUNTA
43=APIVOT(C3:C28,D3:D28,B3:B28,LAMBDA(x,COUNTA(x)))Count of TeamColumn Labels
44PTAppleKiwiLemonLimeOrangeQuinceGTRow LabelsAppleKiwiLemonLimeOrangeQuinceGrand Total
45Amanda112Amanda112
46Bernando112Bernando112
47Carol112Carol112
48Daniel112Daniel112
49Daniela112Daniela112
50Eduardo112Eduardo112
51Gabriel112Gabriel112
52Helena112Helena112
53Isabella112Isabella112
54Jose112Jose112
55Juao Pedro112Juao Pedro112
56Stephanie112Stephanie112
57Thiago112Thiago112
58GT61666126Grand Total61666126
59
PIV 3
Cell Formulas
RangeFormula
G3G3=FORMULATEXT(G6)
N4,N43,N23N4=FORMULATEXT(N5)
N5:U19N5=APIVOT(C3:C28,D3:D28,,LAMBDA(x,SUM(x)))
G6:L18G6=PIVOT(C3:C28,D3:D28,,LAMBDA(x,SUM(x)))
N24:U38N24=APIVOT(C3:C28,D3:D28,,LAMBDA(x,COUNT(x)))
N44:U58N44=APIVOT(C3:C28,D3:D28,B3:B28,LAMBDA(x,COUNTA(x)))
Dynamic array formulas.
 
To visualize the simple concept of PIVOT that is capable of creating an array of arrays we can simply use as function argument "fn" LAMBDA(x,x)
And all this is possible using a single MAKEARRAY function construction found in PIVOT. Everything else build around MAKEARRAY in PIVOT is only cosmetics. APIVOT, that calls PIVOT, is only about cosmetics.
In other words, for every intersection row/clm values ("r"/"c") the corresponded matched values array of "v" is extracted. And to these values we can apply any function that can return a single result or more.
Using LAMBDA(x,x) as function argument ("fn"), PIVOT, (respectivly APIVOT) will return all matched results of the correspondent "r"/"c" intersection conditions.
Note: The default delimiter used in PIVOT as separator between values is ",".
If we want to change it, is the first defined variable "d" after LET in PIVOT.
=LAMBDA(r,c,v,fn,LET(d,",",ur,SORT(UNIQUE(r)), …......
LHPIVOT.xlsx
ABCDEFGHIJKLMNOPQRSTU
1sample array (no headers)
2=APIVOT(B3:B22,D3:D22,E3:E22,LAMBDA(x,x))
3Azb1PTabcdGT
4Bya5A17,741,4,7,7
5Czd7B5,3,326,95,2,3,6,3,9
6Dzc4C3,4,44,477,3,4,4,4,4
7Cxb3D89,944,8,9,9
8Axd4GT5,8,3,31,3,4,9,4,94,2,7,4,7,47,4,6,91,5,7,4,3,4,8,2,7,4,4,9,3,6,7,4,4,9,3,9
9Dya8
10Bxc2=APIVOT(B3:B22,D3:D22,C3:C22,LAMBDA(x,x))
11Ayc7PTabcdGT
12Czc4Azy,yxz,x,y,y
13Czb4By,x,xxz,zy,x,x,z,x,z
14Dyb9Cx,z,zz,zzz,x,z,z,z,z
15Bxa3Dyy,yzz,y,y,y
16Bzd6GTy,y,x,xz,x,z,y,z,yz,x,y,z,y,zz,x,z,zz,y,z,z,x,x,y,x,y,z,z,y,x,z,y,z,z,y,x,zNote: Another advantage of using
17Ayc7lambda helper functions combo PIVOT/APIVOT is
18Czc4that PT interface is not reliable when an array has no headers.
19Czb4checking consistency of the results It will consider first row as headers, therefore results will not be accurate.
20Dyb9=APIVOT(B3:B22,D3:D22,C3:C22,LAMBDA(x,COUNTA(x)))Count of 1Column Labels
21Bxa3PTabcdGTRow LabelsabcdGrand Total
22Bzd9A1214A213
23B3126B3126
24C3216C3216
25D1214D1214
26GT466420Grand Total456419
27
28APIVOT excluding first row:
29=APIVOT(B4:B22,D4:D22,C4:C22,LAMBDA(x,COUNTA(x)))
30PTabcdGT
31A213
32B3126
33C3216
34D1214
35GT456419
36
PIV 4
Cell Formulas
RangeFormula
G2,N29,G20,G10G2=FORMULATEXT(G3)
G3:L8G3=APIVOT(B3:B22,D3:D22,E3:E22,LAMBDA(x,x))
G11:L16G11=APIVOT(B3:B22,D3:D22,C3:C22,LAMBDA(x,x))
G21:L26G21=APIVOT(B3:B22,D3:D22,C3:C22,LAMBDA(x,COUNTA(x)))
N30:S35N30=APIVOT(B4:B22,D4:D22,C4:C22,LAMBDA(x,COUNTA(x)))
Dynamic array formulas.
 
Quirks an Features of PIVOT/APIVOT:
- PIVOT, being designed only for calculations, can be used as stand-alone function, or can be called by other formulas or functions constructions.
- APIVOT can be used as presentation/visualizing interface of PIVOT.
- Can handle arrays with no headers.
- Being lambda helper functions, can handle any functions or formulas constructions.
- Can return more than one result.
- All the arguments r,c,v can be/handle array calculations.
- Last but not least, no refresh.
Simple examples to reflect all these. To be continued, asap(time), with a tone of real-life complex task solving scenarios. More functions, more techniques still to come.
LHPIVOT.xlsx
ABCDEFGHIJKLMNOPQRSTUV
1sample array (no headers)top 2 values including tiesAPIVOT can handle array calculations for its arguments
2fn,LARGE(x,{1,2})all values >=5
3Azb1=APIVOT(B3:B22,D3:D22,E3:E22,LAMBDA(x,LARGE(x,{1,2})))=APIVOT(B3:B22,D3:D22,IF(E3:E22>=5,E3:E22,""),LAMBDA(x,x),"all >=5")
4Bya5PTabcdGTall >=5abcdGT
5Czd7A17,747,7A7,77,7
6Dzc4B8,529,69,8B5,5,86,95,5,6,8,9
7Cxb3C4,44,477,4C77
8Axd4D89,949,9D89,98,9,9
9Dya8GT8,89,97,79,79,9GT5,8,5,89,97,77,6,95,7,8,7,9,5,6,7,9,8,9
10Bxc2
11Ayc7top 2 values excluding tiesvalues >=5
12Czc4fn,LARGE(UNIQUE(x),{1,2})=APIVOT(B3:B22,D3:D22,IF(E3:E22>=5,E3:E22,""),LAMBDA(x,UNIQUE(x)),">=5")
13Czb4PTabcdGT>=5abcdGT
14Dyb9A1747,4A77
15Bxa5B8,529,69,8B5,86,95,6,8,9
16Bzd6C4,3477,4C77
17Ayc7D8949,8D898,9
18Czc4GT8,59,47,49,79,8GT5,8977,6,95,7,8,9,6
19Czb4
20Dyb9unique values distribution x,y,z
21Bxa8fn,SORT(UNIQUE(x))count values >=5
22Bzd9=APIVOT(B3:B22,D3:D22,C3:C22,LAMBDA(x,SORT(UNIQUE(x))),"xyz distrib")=APIVOT(B3:B22,D3:D22,IF(E3:E22>=5,E3:E22,""),LAMBDA(x,COUNT(x)),"cnt >=5")
23xyz distribabcdGTcnt >=5abcdGT
24Azyxx,y,zA22
25Bx,yxzx,y,zB325
26Cx,zzzx,zC11
27Dyyzy,zD123
28GTx,yx,y,zx,y,zx,zx,y,zGT422311
29
30sum distribution all a,b,c,dsum distribution for a,b ; c and d cumulated as "others"
31=APIVOT(B3:B22,D3:D22,E3:E22,LAMBDA(x,SUM(x)),"sum")=APIVOT(B3:B22,IF((D3:D22="a")+(D3:D22="b"),D3:D22,"other"),E3:E22,LAMBDA(x,SUM(x)),"a,b")
32sumabcdGTa,babotherGT
33A114419A11819
34B1821535B181735
35C118726C111526
36D818430D818430
37GT26302826110GT263054110
38
PIV 5
Cell Formulas
RangeFormula
G3,G31,G22,O22,O12,O3G3=FORMULATEXT(G4)
G4:L9G4=APIVOT(B3:B22,D3:D22,E3:E22,LAMBDA(x,LARGE(x,{1,2})))
O4:T9O4=APIVOT(B3:B22,D3:D22,IF(E3:E22>=5,E3:E22,""),LAMBDA(x,x),"all >=5")
G13:L18G13=APIVOT(B3:B22,D3:D22,E3:E22,LAMBDA(x,LARGE(UNIQUE(x),{1,2})))
O13:T18O13=APIVOT(B3:B22,D3:D22,IF(E3:E22>=5,E3:E22,""),LAMBDA(x,UNIQUE(x)),">=5")
G23:L28G23=APIVOT(B3:B22,D3:D22,C3:C22,LAMBDA(x,SORT(UNIQUE(x))),"xyz distrib")
O23:T28O23=APIVOT(B3:B22,D3:D22,IF(E3:E22>=5,E3:E22,""),LAMBDA(x,COUNT(x)),"cnt >=5")
N31N31=FORMULATEXT(O32)
G32:L37G32=APIVOT(B3:B22,D3:D22,E3:E22,LAMBDA(x,SUM(x)),"sum")
O32:S37O32=APIVOT(B3:B22,IF((D3:D22="a")+(D3:D22="b"),D3:D22,"other"),E3:E22,LAMBDA(x,SUM(x)),"a,b")
Dynamic array formulas.
 
Since APIVOT arguments can take array calculations, manipulating dates comes handy.
Check out Leila's PT techniques YT: Properly Handling Date Grouping in Excel Pivot Tables (Change Grouping, Get All dates)
workbook download link: Excel Pivot Table Date Grouping - Xelplus - Leila Gharani
LHPIVOT.xlsx
ABCDEFGHIJKLMNOPQ
1sample table 600 rows=APIVOT(TEXT(S[Order date],"yyyy-(mm)-mmm"),,S[Order amount],LAMBDA(x,SUM(x)),"Year-Month","Tot Orders")
2SalespersonOrder IDOrder dateOrder amount=SORT(UNIQUE(S[Salesperson]))
3Jack Potter328404-01-214686.243939Year-MonthTot OrdersDV formula
4Bob Caldwell328504-01-2117702.126922021-(01)-Jan567729.4435Amy Trefl
5Bob Caldwell328605-01-218563.4691322021-(02)-Feb691142.9563Anthony Grosse
6Taj Shand328706-01-2120481.330252021-(03)-Mar658502.6592Archer Lamble
7Jack Potter328809-01-2115780.993342021-(04)-Apr495310.5648Bob Caldwell
8Justine Hoffer328911-01-217270.7949362021-(05)-May458611.6175Don Johnson
9Sheridan Smith329011-01-215840.1692972021-(06)-Jun373276.693Hudson Hollinworth
10Taj Shand329111-01-2115376.807142021-(07)-Jul591065.3804Hudson Onslow
11Archer Lamble329212-01-2123132.982032021-(08)-Aug457049.7136Jack Potter
12Hudson Hollinworth329312-01-2119249.777662021-(09)-Sep766123.202Justine Hoffer
13Hudson Onslow329412-01-2118854.760982021-(10)-Oct606950.1752Kayla Woodcock
14Justine Hoffer329512-01-2121544.813062021-(11)-Nov690283.5764Lily Code
15Taj Shand329613-01-2123344.867172021-(12)-Dec813876.6413Peter Chowdhry
16Don Johnson329715-01-2115420.931392022-(01)-Jan730249.9767Sheridan Smith
17Amy Trefl329816-01-2115300.264472022-(02)-Feb604319.1448Sophia Hinton
18Lily Code329918-01-218091.068995GT8504491.745Taj Shand
19Hudson Onslow330018-01-2116146.70696
20Bob Caldwell330118-01-215858.817495
21Kayla Woodcock330219-01-2118023.42206=APIVOT(WEEKDAY(S[Order date],2)&"-"&TEXT(S[Order date],"ddd"),,S[Order amount],LAMBDA(x,SUM(x)),"SUM/wdays")
22Sheridan Smith330320-01-2121212.95523SUM/wdaysGT
23Hudson Hollinworth330421-01-216270.7275471-Mon2357492.283Selection
24Archer Lamble330521-01-2111684.544992-Tue1259545.731DV Salesperson
25Sophia Hinton330621-01-2123250.868073-Wed1133082.268Archer Lamble
26Hudson Onslow330721-01-215584.4120334-Thu1137252.179Lily Code
27Hudson Hollinworth330821-01-2118973.509985-Fri1257000.392
28Kayla Woodcock330923-01-2115544.879426-Sat1360118.893
29Sophia Hinton331025-01-219941.138917GT8504491.745
30Lily Code331125-01-215418.414547
31Hudson Onslow331226-01-2116683.98206=APIVOT(TEXT(S[Order date],"yyyy-(mm)-mmm"),IF(ISNUMBER(XMATCH(S[Salesperson],J25:J26)),S[Salesperson],"Ꝋthers"),S[Order amount],LAMBDA(x,SUM(x)),"SUM Selection")
32Amy Trefl331328-01-2121285.61157SUM SelectionArcher LambleLily CodeꝊthersGT=IFERROR(G33:G47+H33:H47,"")
33Bob Caldwell331428-01-2117873.080372021-(01)-Jan45797.3006413509.48354508422.6593567729.443559306.78419
34Amy Trefl331529-01-2118233.579372021-(02)-Feb34954.9209231727.6317624460.4037691142.956366682.55262
35Amy Trefl331629-01-2120485.994422021-(03)-Mar52455.9143839902.49664566144.2481658502.659292358.41102
36Archer Lamble331729-01-2110979.773622021-(04)-Apr13984.29783481326.267495310.5648
37Hudson Hollinworth331829-01-2116994.455542021-(05)-May9768.43214243178.77407405664.4112458611.617552947.20622
38Justine Hoffer331930-01-219521.6010812021-(06)-Jun22514.2434110012.9606340749.4889373276.69332527.20401
39Bob Caldwell332030-01-219560.2603412021-(07)-Jul34064.86321101145.9112455854.606591065.3804135210.7744
40Sheridan Smith332130-01-2114020.608022021-(08)-Aug14390.2614958419.51281384239.9393457049.713672809.7743
41Bob Caldwell332230-01-2113538.699122021-(09)-Sep38575.42867727547.7733766123.202
42Bob Caldwell332301-02-2121596.070582021-(10)-Oct10239.0428750764.67789545946.4545606950.175261003.72077
43Sheridan Smith332401-02-218228.7962332021-(11)-Nov70241.5688222955.95445597086.0531690283.576493197.52327
44Kayla Woodcock332501-02-2124965.015882021-(12)-Dec50230.87472126931.199636714.5677813876.6413177162.0737
45Don Johnson332601-02-2114049.725322022-(01)-Jan30490.9917559606.79675640152.1882730249.976790097.78851
46Hudson Hollinworth332701-02-2113880.847072022-(02)-Feb25638.8563937906.4995540773.7889604319.144863545.35589
47Justine Hoffer332801-02-2123031.95227GT439362.6994610046.19597455082.8498504491.7451049408.895
48Anthony Grosse332901-02-2122969.89558
49Jack Potter333002-02-2113545.11058
50Bob Caldwell333102-02-216750.206713Omega char=UNICODE(H51)
51Anthony Grosse333202-02-2111978.3404442826
52Don Johnson333302-02-2114838.46588
PIV 6
Cell Formulas
RangeFormula
F1,J2F1=FORMULATEXT(F3)
F3:G18F3=APIVOT(TEXT(S[Order date],"yyyy-(mm)-mmm"),,S[Order amount],LAMBDA(x,SUM(x)),"Year-Month","Tot Orders")
J4:J18J4=SORT(UNIQUE(S[Salesperson]))
F21,I50,L32,F31F21=FORMULATEXT(F22)
F22:G29F22=APIVOT(WEEKDAY(S[Order date],2)&"-"&TEXT(S[Order date],"ddd"),,S[Order amount],LAMBDA(x,SUM(x)),"SUM/wdays")
F32:J47F32=APIVOT(TEXT(S[Order date],"yyyy-(mm)-mmm"),IF(ISNUMBER(XMATCH(S[Salesperson],J25:J26)),S[Salesperson],"Ꝋthers"),S[Order amount],LAMBDA(x,SUM(x)),"SUM Selection")
L33:L47L33=IFERROR(G33:G47+H33:H47,"")
I51I51=UNICODE(H51)
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
J25:J29List=$J$4#
 
To solve Quarter grouping challenge here is QTR function. Capable of dealing also with fiscal quarters/years, not only with calendar ones.
Start month (s), of fiscal year by country can be different. Most common s's are 4,7,10.
The function uses by default s=4 (April) To change this value, change the first variable "s" , first variable declared after LET.
QTR(a,[qt])
a: dates array
[qt]: quarter type argument, text, could be one of these values:
"q": calendar quarter
"qy": calendar quarter and year, (year will be listed first for sorting versatility) ; format ex.: 2022 Q3
"fq": fiscal quarter : format ex.: FQ4
"fy": fiscal year ; format ex.: FY 2023 (represents fiscal year 2022-2023)
"fqy": fiscal quarter and year, (year will be listed first for sorting versatility) ; format ex.: FY 2022 Q2
- if qt is omitted, function will calculate "qy", if qt<> above values function returns #NA() error
Excel Formula:
=LAMBDA(a, [qt],
    LET(
        s, 4,
        m, MONTH(a),
        y, YEAR(a),
        q, "Q" & MONTH(m & 0),
        qy, y & " " & q,
        fq, "Q" & MONTH(MOD(m - s, 12) + 1 & 0),
        fy, "FY " & y + (m >= s),
        fqy, fy & " " & fq,
        SWITCH(qt, 0, qy, "q", q, "qy", qy, "fq", "F" & fq, "fy", fy, "fqy", fqy)
    )
)
LHPIVOT.xlsx
ABCDEFGHIJKLMNOPQ
1QTR(a,[qt]). The function.
2wrong argument
3=DATE(2021,SEQUENCE(24),1)qt,omittedqt,"q"qt,"qy"qt,"fq"qt,"fy"qt,"fqy"qt,"fyq"
4↓↓↓=QTR(B5#)=QTR(B5#,"q")=QTR(B5#,"qy")=QTR(B5#,"fq")=QTR(B5#,"fy")=QTR(B5#,"fqy")=QTR(B5#,"fyq")
501-01-212021 Q1Q12021 Q1FQ4FY 2021FY 2021 Q4#N/A
601-02-212021 Q1Q12021 Q1FQ4FY 2021FY 2021 Q4
701-03-212021 Q1Q12021 Q1FQ4FY 2021FY 2021 Q4
801-04-212021 Q2Q22021 Q2FQ1FY 2022FY 2022 Q1
901-05-212021 Q2Q22021 Q2FQ1FY 2022FY 2022 Q1
1001-06-212021 Q2Q22021 Q2FQ1FY 2022FY 2022 Q1
1101-07-212021 Q3Q32021 Q3FQ2FY 2022FY 2022 Q2
1201-08-212021 Q3Q32021 Q3FQ2FY 2022FY 2022 Q2
1301-09-212021 Q3Q32021 Q3FQ2FY 2022FY 2022 Q2
1401-10-212021 Q4Q42021 Q4FQ3FY 2022FY 2022 Q3
1501-11-212021 Q4Q42021 Q4FQ3FY 2022FY 2022 Q3
1601-12-212021 Q4Q42021 Q4FQ3FY 2022FY 2022 Q3
1701-01-222022 Q1Q12022 Q1FQ4FY 2022FY 2022 Q4
1801-02-222022 Q1Q12022 Q1FQ4FY 2022FY 2022 Q4
1901-03-222022 Q1Q12022 Q1FQ4FY 2022FY 2022 Q4
2001-04-222022 Q2Q22022 Q2FQ1FY 2023FY 2023 Q1
2101-05-222022 Q2Q22022 Q2FQ1FY 2023FY 2023 Q1
2201-06-222022 Q2Q22022 Q2FQ1FY 2023FY 2023 Q1
2301-07-222022 Q3Q32022 Q3FQ2FY 2023FY 2023 Q2
2401-08-222022 Q3Q32022 Q3FQ2FY 2023FY 2023 Q2
2501-09-222022 Q3Q32022 Q3FQ2FY 2023FY 2023 Q2
2601-10-222022 Q4Q42022 Q4FQ3FY 2023FY 2023 Q3
2701-11-222022 Q4Q42022 Q4FQ3FY 2023FY 2023 Q3
2801-12-222022 Q4Q42022 Q4FQ3FY 2023FY 2023 Q3
29
PIV 7
Cell Formulas
RangeFormula
A3A3=FORMULATEXT(B5)
F4,H4,J4,L4,N4,P4,D4F4=FORMULATEXT(F5)
B5:B28B5=DATE(2021,SEQUENCE(24),1)
D5:D28D5=QTR(B5#)
F5:F28F5=QTR(B5#,"q")
H5:H28H5=QTR(B5#,"qy")
J5:J28J5=QTR(B5#,"fq")
L5:L28L5=QTR(B5#,"fy")
N5:N28N5=QTR(B5#,"fqy")
P5P5=QTR(B5#,"fyq")
Dynamic array formulas.
 
Fiscal/Calendar year/quarter reports with APIVOT.
LHPIVOT.xlsx
ABCDEFGHIJKLMN
1sample table 600 rows=APIVOT(QTR(S[Order date]),,S[Order amount],LAMBDA(x,SUM(x)))
2SalespersonOrder IDOrder dateOrder amount↓↓↓=APIVOT(QTR(S[Order date],"q"),,S[Order amount],LAMBDA(x,SUM(x)))
3Jack Potter328404-01-214686.243939↓↓↓↓↓↓Pivot table check
4Bob Caldwell328504-01-2117702.12692PTGTPTGTRow LabelsSum of Order amount
5Bob Caldwell328605-01-218563.4691322021 Q11917375.059Q13251944.18Qtr13251944.18
6Taj Shand328706-01-2120481.330252021 Q21327198.875Q21327198.875Qtr21327198.875
7Jack Potter328809-01-2115780.993342021 Q31814238.296Q31814238.296Qtr31814238.296
8Justine Hoffer328911-01-217270.7949362021 Q42111110.393Q42111110.393Qtr42111110.393
9Sheridan Smith329011-01-215840.1692972022 Q11334569.122GT8504491.745Grand Total8504491.745
10Taj Shand329111-01-2115376.80714GT8504491.745
11Archer Lamble329212-01-2123132.98203
12Hudson Hollinworth329312-01-2119249.77766=APIVOT(QTR(S[Order date],"fq"),,S[Order amount],LAMBDA(x,SUM(x)))
13Hudson Onslow329412-01-2118854.76098PTGT
14Justine Hoffer329512-01-2121544.81306FQ11327198.875=APIVOT(QTR(S[Order date],"fy"),,S[Order amount],LAMBDA(x,SUM(x)))
15Taj Shand329613-01-2123344.86717FQ21814238.296PTGT
16Don Johnson329715-01-2115420.93139FQ32111110.393FY 20211917375.059
17Amy Trefl329816-01-2115300.26447FQ43251944.18FY 20226587116.686Pivot Table check (values F4:G10)
18Lily Code329918-01-218091.068995GT8504491.745GT8504491.745Row LabelsSum of Order amount
19Hudson Onslow330018-01-2116146.706962021
20Bob Caldwell330118-01-215858.817495=APIVOT(QTR(S[Order date],"fqy"),,S[Order amount],LAMBDA(x,SUM(x)))Qtr11917375.059
21Kayla Woodcock330219-01-2118023.42206PTGTQtr21327198.875
22Sheridan Smith330320-01-2121212.95523FY 2021 Q41917375.059Qtr31814238.296
23Hudson Hollinworth330421-01-216270.727547FY 2022 Q11327198.875Qtr42111110.393
24Archer Lamble330521-01-2111684.54499FY 2022 Q21814238.2962022
25Sophia Hinton330621-01-2123250.86807FY 2022 Q32111110.393Qtr11334569.122
26Hudson Onslow330721-01-215584.412033FY 2022 Q41334569.122Grand Total8504491.745
27Hudson Hollinworth330821-01-2118973.50998GT8504491.745
28Kayla Woodcock330923-01-2115544.87942
29Sophia Hinton331025-01-219941.138917Checking quarter values summing correspondent month
30Lily Code331125-01-215418.414547=APIVOT(TEXT(S[Order date],"yy-(mm)-mmm"),,S[Order amount],LAMBDA(x,SUM(x)))
31Hudson Onslow331226-01-2116683.98206PTGTPivot table check
32Amy Trefl331328-01-2121285.6115721-(01)-Jan567729.4435Row LabelsSum of Order amount
33Bob Caldwell331428-01-2117873.0803721-(02)-Feb691142.9563=SUM(G32:G34)=G52021
34Amy Trefl331529-01-2118233.5793721-(03)-Mar658502.6592TRUEJan567729.4435
35Amy Trefl331629-01-2120485.9944221-(04)-Apr495310.5648Feb691142.9563
36Archer Lamble331729-01-2110979.7736221-(05)-May458611.6175=SUM(G35:G37)=G6Mar658502.6592
37Hudson Hollinworth331829-01-2116994.4555421-(06)-Jun373276.693TRUEApr495310.5648
38Justine Hoffer331930-01-219521.60108121-(07)-Jul591065.3804May458611.6175
39Bob Caldwell332030-01-219560.26034121-(08)-Aug457049.7136=SUM(G38:G40)=G7Jun373276.693
40Sheridan Smith332130-01-2114020.6080221-(09)-Sep766123.202TRUEJul591065.3804
41Bob Caldwell332230-01-2113538.6991221-(10)-Oct606950.1752Aug457049.7136
42Bob Caldwell332301-02-2121596.0705821-(11)-Nov690283.5764=SUM(G41:G43)=G8Sep766123.202
43Sheridan Smith332401-02-218228.79623321-(12)-Dec813876.6413TRUEOct606950.1752
44Kayla Woodcock332501-02-2124965.0158822-(01)-Jan730249.9767=SUM(G44:G45)=G9Nov690283.5764
45Don Johnson332601-02-2114049.7253222-(02)-Feb604319.1448TRUEDec813876.6413
46Hudson Hollinworth332701-02-2113880.84707GT8504491.7452022
47Justine Hoffer332801-02-2123031.95227Jan730249.9767
48Anthony Grosse332901-02-2122969.89558Feb604319.1448
49Jack Potter333002-02-2113545.11058table rowsGrand Total8504491.745
50Bob Caldwell333102-02-216750.206713=ROWS(S)
51Anthony Grosse333202-02-2111978.34044600
52Don Johnson333302-02-2114838.46588
PIV 8
Cell Formulas
RangeFormula
F1F1=FORMULATEXT(F4)
I2I2=FORMULATEXT(I4)
F4:G10F4=APIVOT(QTR(S[Order date]),,S[Order amount],LAMBDA(x,SUM(x)))
I4:J9I4=APIVOT(QTR(S[Order date],"q"),,S[Order amount],LAMBDA(x,SUM(x)))
F12,F50,I44,I42,I39,I36,I33,F30,F20,I14F12=FORMULATEXT(F13)
F13:G18F13=APIVOT(QTR(S[Order date],"fq"),,S[Order amount],LAMBDA(x,SUM(x)))
I15:J18I15=APIVOT(QTR(S[Order date],"fy"),,S[Order amount],LAMBDA(x,SUM(x)))
F21:G27F21=APIVOT(QTR(S[Order date],"fqy"),,S[Order amount],LAMBDA(x,SUM(x)))
F31:G46F31=APIVOT(TEXT(S[Order date],"yy-(mm)-mmm"),,S[Order amount],LAMBDA(x,SUM(x)))
I34I34=SUM(G32:G34)=G5
I37I37=SUM(G35:G37)=G6
I40I40=SUM(G38:G40)=G7
I43I43=SUM(G41:G43)=G8
I45I45=SUM(G44:G45)=G9
F51F51=ROWS(S)
Dynamic array formulas.
 
Task: Report top/last 3 Order amounts values per each month for each Salesperson.
LHPIVOT.xlsx
ABCDEFGHIJKLMNOPQ
1sample table 600 rows
2SalespersonOrder IDOrder dateOrder amount
3Jack Potter328404-01-214686.243939
4Bob Caldwell328504-01-2117702.12692=APIVOT(TEXT(S[Order date],"yy-(mm)-mmmm"),,S[Order amount],LAMBDA(x,LARGE(INT(x),SEQUENCE(3))),"Top 3/mnth","top 3","top 3 all time")
5Bob Caldwell328605-01-218563.469132Top 3/mnthtop 3
6Taj Shand328706-01-2120481.3302521-(01)-January23344, 23250, 23132
7Jack Potter328809-01-2115780.9933421-(02)-February24965, 24304, 23126
8Justine Hoffer328911-01-217270.79493621-(03)-March24517, 24219, 23842
9Sheridan Smith329011-01-215840.16929721-(04)-April24585, 23927, 23855
10Taj Shand329111-01-2115376.8071421-(05)-May23970, 22518, 19514
11Archer Lamble329212-01-2123132.9820321-(06)-June24594, 24413, 22697
12Hudson Hollinworth329312-01-2119249.7776621-(07)-July24720, 24162, 23942
13Hudson Onslow329412-01-2118854.7609821-(08)-August24100, 24004, 23602
14Justine Hoffer329512-01-2121544.8130621-(09)-September23455, 23261, 23227
15Taj Shand329613-01-2123344.8671721-(10)-October24939, 23697, 23659
16Don Johnson329715-01-2115420.9313921-(11)-November24714, 24282, 24245
17Amy Trefl329816-01-2115300.2644721-(12)-December23874, 23868, 23514
18Lily Code329918-01-218091.06899522-(01)-January24782, 24197, 23916
19Hudson Onslow330018-01-2116146.7069622-(02)-February24999, 24097, 23445
20Bob Caldwell330118-01-215858.817495top 3 all time24999, 24965, 24939
21Kayla Woodcock330219-01-2118023.42206
22Sheridan Smith330320-01-2121212.95523
23Hudson Hollinworth330421-01-216270.727547=APIVOT(TEXT(S[Order date],"yy-(mm)-mmmm"),,S[Order amount],LAMBDA(x,SMALL(INT(x),SEQUENCE(3))),"Last 3/mnth","last 3","last 3 all time")
24Archer Lamble330521-01-2111684.54499Last 3/mnthlast 3
25Sophia Hinton330621-01-2123250.8680721-(01)-January4686, 5418, 5584
26Hudson Onslow330721-01-215584.41203321-(02)-February4070, 4580, 4901
27Hudson Hollinworth330821-01-2118973.5099821-(03)-March4113, 4426, 4502
28Kayla Woodcock330923-01-2115544.8794221-(04)-April4589, 5057, 5174
29Sophia Hinton331025-01-219941.13891721-(05)-May4304, 4745, 4873
30Lily Code331125-01-215418.41454721-(06)-June4776, 5091, 5236
31Hudson Onslow331226-01-2116683.9820621-(07)-July5204, 6209, 6743
32Amy Trefl331328-01-2121285.6115721-(08)-August4731, 5012, 5385
33Bob Caldwell331428-01-2117873.0803721-(09)-September4428, 4430, 4783
34Amy Trefl331529-01-2118233.5793721-(10)-October4018, 4841, 5100
35Amy Trefl331629-01-2120485.9944221-(11)-November4319, 4546, 5049
36Archer Lamble331729-01-2110979.7736221-(12)-December4259, 4279, 4396
37Hudson Hollinworth331829-01-2116994.4555422-(01)-January4024, 4113, 4464
38Justine Hoffer331930-01-219521.60108122-(02)-February4189, 4398, 7060
39Bob Caldwell332030-01-219560.260341last 3 all time4018, 4024, 4070
40Sheridan Smith332130-01-2114020.60802
41Bob Caldwell332230-01-2113538.69912
PIV 9
Cell Formulas
RangeFormula
F4,F23F4=FORMULATEXT(F5)
F5:G20F5=APIVOT(TEXT(S[Order date],"yy-(mm)-mmmm"),,S[Order amount],LAMBDA(x,LARGE(INT(x),SEQUENCE(3))),"Top 3/mnth","top 3","top 3 all time")
F24:G39F24=APIVOT(TEXT(S[Order date],"yy-(mm)-mmmm"),,S[Order amount],LAMBDA(x,SMALL(INT(x),SEQUENCE(3))),"Last 3/mnth","last 3","last 3 all time")
Dynamic array formulas.
 
Task 1: Total nr. of Orders registered/Salesperson entire period.
Task 2: How many Salespersons registered at least one order each month of every year.
Task 3: What Salespersons did not register any Order per month and year.

LHPIVOT.xlsx
ABCDEFGHIJKLMNOPQR
1sample table 600 rows
2SalespersonOrder IDOrder dateOrder amount
3Jack Potter328404-01-214686.243939Task 1
4Bob Caldwell328504-01-2117702.12692=APIVOT(S[Salesperson],,S[Order amount],LAMBDA(x,COUNT(x)))
5Bob Caldwell328605-01-218563.469132↓↓↓
6Taj Shand328706-01-2120481.33025↓↓↓Task 3
7Jack Potter328809-01-2115780.99334PTGT=APIVOT(TEXT(S[Order date],"yy (mm) mmm"),,S[Salesperson],LAMBDA(x,FILTER(F8:F22,ISNA(XMATCH(F8:F22,SORT(UNIQUE(x)))))))
8Justine Hoffer328911-01-217270.794936Amy Trefl35PTGT
9Sheridan Smith329011-01-215840.169297Anthony Grosse4321 (01) JanAnthony Grosse, Peter Chowdhry
10Taj Shand329111-01-2115376.80714Archer Lamble3421 (02) Feb
11Archer Lamble329212-01-2123132.98203Bob Caldwell4221 (03) Mar
12Hudson Hollinworth329312-01-2119249.77766Don Johnson4621 (04) AprArcher Lamble, Sophia Hinton
13Hudson Onslow329412-01-2118854.76098Hudson Hollinworth4021 (05) MaySophia Hinton
14Justine Hoffer329512-01-2121544.81306Hudson Onslow3421 (06) JunJustine Hoffer
15Taj Shand329613-01-2123344.86717Jack Potter2921 (07) JulJack Potter
16Don Johnson329715-01-2115420.93139Justine Hoffer5521 (08) AugAmy Trefl
17Amy Trefl329816-01-2115300.26447Kayla Woodcock3921 (09) SepLily Code
18Lily Code329918-01-218091.068995Lily Code4121 (10) Oct
19Hudson Onslow330018-01-2116146.70696Peter Chowdhry3521 (11) NovHudson Onslow
20Bob Caldwell330118-01-215858.817495Sheridan Smith4321 (12) Dec
21Kayla Woodcock330219-01-2118023.42206Sophia Hinton3422 (01) Jan
22Sheridan Smith330320-01-2121212.95523Taj Shand5022 (02) FebKayla Woodcock, Peter Chowdhry
23Hudson Hollinworth330421-01-216270.727547GT600GT
24Archer Lamble330521-01-2111684.54499
25Sophia Hinton330621-01-2123250.86807
26Hudson Onslow330721-01-215584.412033Task 2
27Hudson Hollinworth330821-01-2118973.50998=APIVOT(TEXT(S[Order date],"yy (mm) mmm"),,S[Salesperson],LAMBDA(x,COUNTA(SORT(UNIQUE(x)))))
28Kayla Woodcock330923-01-2115544.87942PTGT
29Sophia Hinton331025-01-219941.13891721 (01) Jan13
30Lily Code331125-01-215418.41454721 (02) Feb15
31Hudson Onslow331226-01-2116683.9820621 (03) Mar15
32Amy Trefl331328-01-2121285.6115721 (04) Apr13
33Bob Caldwell331428-01-2117873.0803721 (05) May14
34Amy Trefl331529-01-2118233.5793721 (06) Jun14
35Amy Trefl331629-01-2120485.9944221 (07) Jul14
36Archer Lamble331729-01-2110979.7736221 (08) Aug14
37Hudson Hollinworth331829-01-2116994.4555421 (09) Sep14
38Justine Hoffer331930-01-219521.60108121 (10) Oct15
39Bob Caldwell332030-01-219560.26034121 (11) Nov14
40Sheridan Smith332130-01-2114020.6080221 (12) Dec15
41Bob Caldwell332230-01-2113538.6991222 (01) Jan15
42Bob Caldwell332301-02-2121596.0705822 (02) Feb13
43Sheridan Smith332401-02-218228.796233GT15
44Kayla Woodcock332501-02-2124965.01588
45Don Johnson332601-02-2114049.72532
PIV 10
Cell Formulas
RangeFormula
F4F4=FORMULATEXT(F7)
F7:G23F7=APIVOT(S[Salesperson],,S[Order amount],LAMBDA(x,COUNT(x)))
I7,F27I7=FORMULATEXT(I8)
I8:J23I8=APIVOT(TEXT(S[Order date],"yy (mm) mmm"),,S[Salesperson],LAMBDA(x,FILTER(F8:F22,ISNA(XMATCH(F8:F22,SORT(UNIQUE(x)))))))
F28:G43F28=APIVOT(TEXT(S[Order date],"yy (mm) mmm"),,S[Salesperson],LAMBDA(x,COUNTA(SORT(UNIQUE(x)))))
Dynamic array formulas.
 

Forum statistics

Threads
1,223,248
Messages
6,171,021
Members
452,374
Latest member
keccles

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