Complex calculations on a table's results

gaspafter26

New member
Joined
Oct 16, 2021
Messages
2
Reaction score
0
Points
0
Excel Version(s)
Microsoft 365
The underlying data looks like this
accountnamemonthsales
1090HertzJan-2113
1090HertzFeb-217
1090HertzMar-218
1090HertzApr-212
1121AvisJan-214
1121AvisFeb-217
1121AvisMar-219
1121AvisApr-211
1311BudgetJan-217
1311BudgetFeb-217
1311BudgetMar-213
1311BudgetApr-215
1002AlamoJan-213
1002AlamoFeb-212
1002AlamoMar-212
1002AlamoApr-210

The pivot table looks like this

Sum of salesMonths
accountname Jan Feb Mar AprGrand Total
1002Alamo32207
1090Hertz1378230
1121Avis479121
1311Budget773522
Grand Total272322880

My objective is to do a more complex calculation - I want to show only those records where at least 2 of the last 3 months, the sales are 5 or less.

I tried to add a calculated item, but the error I get says too many records, and I have not been able to solve that

I've tried endless hacks to work outside the pivot table, but none work.

Can someone point me in the direction of a solution?
 
In the attached is your pivot at cell G2, then at cell G18 there's a pivot based on a query of the table at cell A1.
The query does the following:
  • Grabs the table at cell A1
  • Works out a cutoff date by subtracting 3 months from the latest date in the table
  • Filters the table for only dates after that cutoff (the last 3 months)
  • Filters the table for sales <=5
  • Groups using account and name counting how many rows in each group
  • Filters that count for 2 or more which leaves us with a small table of accounts and names
  • which is merged (joined) with the original table to retrieve all the months' data for just those accounts/names
  • which is then pivoted on the sheet.
 

Attachments

  • ExcelGuru11332.xlsx
    23.2 KB · Views: 9
Last edited:
Thanks very much for this. You have pointed me where I need to go, much appreciated.


In the attached is your pivot at cell G2, then at cell G18 there's a pivot based on a query of the table at cell A1.
The query does the following:
  • Grabs the table at cell A1
  • Works out a cutoff date by subtracting 3 months from the latest date in the table
  • Filters the table for only dates after that cutoff (the last 3 months)
  • Filters the table for sales <=5
  • Groups using account and name counting how many rows in each group
  • Filters that count for 2 or more which leaves us with a small table of accounts and names
  • which is merged (joined) with the original table to retrieve all the months' data for just those accounts/names
  • which is then pivoted on the sheet.
 
Back
Top