r/excel • • Jan 28 '26 • Mindblown 1

solved Modified PIVOTBY solution to insert additional aggregations for each unique row block

Hi I have the following dataset:

AreaItemMonthTargetActual
NorthMobilesJan-25100100
NorthMobilesFeb-2550120
NorthMobilesMar-2520050
SouthPCJan-25100200
SouthPCFeb-2550100
SouthPCMar-2520050
SouthMobilesJan-25100100
SouthMobilesFeb-2550150
SouthMobilesMar-2520050

My required result is in this format :

AreaItemMeasureJan-25Feb-25Mar-25
NorthMobilesTarget10050200
NorthMobilesActual10012050
NorthMobilesRunn. Target100150350
NorthMobilesRunn.Actual100220270
NorthMobilesTotal Variance070-80
SouthPCTarget10050200
SouthPCActual20010050
SouthPCRunn. Target100150350
SouthPCRunn.Actual200300350
SouthPCTotal Variance1001500
SouthMobilesTarget10050200
SouthMobilesActual10015050
SouthMobilesRunn. Target100150350
SouthMobilesRunn.Actual100250300
SouthMobilesTotal Variance0100-50

With native PIVOTBY, Im only able to get the first two measures.( Target & Actual )

Im looking for a dynamic solution to get the other three measures also for each unique Area-item Combo and they need to be inserted in the same order

5 Upvotes

17 comments sorted by

View all comments

Show parent comment

2

u/land_cruizer Jan 29 '26

Works great ! Solution Verified

Just a quick one, since all the code is dynamic, is there an easy modification to allow for additional category columns ( can be assigned as a LET variable ) ?

1

u/reputatorbot Jan 29 '26

You have awarded 1 point to MayukhBhattacharya.


I am a bot - please contact the mods with any questions

1

u/MayukhBhattacharya 1327 Jan 29 '26

Oh yes most definitely, Variables _b, P ( PIVOTBY() to summarize data by grouping rows and columns), R ( MAP() function for rolling/running sum) and make sure to make _f <> "", where you need to consider for additional category columns. Thank You SO Much, for your valuable feedback.