0

I have a table with dates, and two value columns, Item 1 and Item 2.

Example Excel data table

I want to make a PivotTable with the maximum monthly value for Item 1 and Item 2.

This works as expected. I then want to sum those maximum values, to get a total of the maximum for Item 1 and Item 2, in the PivotTable.

I have tried used a calculated field with both:

=SUM(MAX(' Item 1'), MAX(' Item 2')) and =SUM('Item 1','Item 2').

But this sums all the values from that month for Item 1 and Item 2, not only the maximums. It is easy to do with a formula outside the PivotTable, but I would like to do this within the PivotTable so I can chart it and add new data in the future. The image below shows the results of the two calculated fields described above (in red), and a simple formula outside the PivotTable, which gives the desired result (in green).

Resulting PivotTable and desired result

I am using Excel Professional Plus 2016 on Windows 10. Below is example data if you want to try.

Date    Item 1  Item 2
01/01/2020  2   8
02/01/2020  3   6
03/01/2020  5   4
04/01/2020  3   7
05/01/2020  5   4
06/01/2020  2   7
07/01/2020  3   4
01/02/2020  7   6
02/02/2020  3   4
03/02/2020  6   3
04/02/2020  3   7
05/02/2020  2   8
06/02/2020  5   7
07/02/2020  5   3
01/03/2020  3   8
02/03/2020  5   6
03/03/2020  7   3
04/03/2020  8   7
05/03/2020  3   4
06/03/2020  2   2
07/03/2020  5   5
9
  • Hi @gisol,, your data set with DATEs has an issue since DATEs are in sequence therefore not suitable for SUMMARIZE them using PT/CONSOLIDATE,,, each DATE should have multiple entries,, since are not !! Apr 13, 2020 at 6:15
  • In the PivotTable, I am grouping by month, so every row (month) has multiple values. So I'm not sure this is an issue. The Max of Item 1 and Max of Item 2 show the largest value from within that month, as intended. What I want to do, is sum those largest-values for each month.
    – gisol
    Apr 14, 2020 at 1:57
  • Hi @gisol ,, check the attached data are dates in sequence and if you apply Month format on cells will so U Jan ,Feb & others but if U create PT/Data Consolidation, Excel will read the Dates in sequence and never create summary,,, PT summarizes data in Row in that case each moth will in single row value !! Apr 14, 2020 at 6:37
  • Cont,,, if U have 01/01/20 in A1:A5, & apply Month format and create PT/Consolidate,, U get single Row for JAN and so others !! But never with your data. Apr 14, 2020 at 6:41
  • Thanks for the response. I'm not totally clear, but I have tested again with non-sequential days and non-sequential months, and repeated days within months, and I have the same result every time. The only difference being the months were out of order in the summary PivotTable, but it is trivial to right click and sort the PivotTable. I wonder if you are copying my example data without using Text to Columns?
    – gisol
    Apr 14, 2020 at 10:15

1 Answer 1

1
+50

I suspect the plain pivot table function in excel is not enough to compute the min() and max() in a certain pivot table set, since the min() and max() functions are supposed to work in a row-by-row basis only. You need to create a "measure" (e.g. max of a certain group of cells, you may say they are calculated fields which can be manipulated more) to tell excel the expression to compute the value for a group of cells for you. This does not seems to work in plain old pivot table.

However, this functionality is provided in PowerPivot within MsExcel, which is using the DAX expression to create "measures" (simular to calculated fields but can be manipulated with DAX functions). Normally this addin is not enabled, so you need to enable it in COM-addin.

If you are using MSOffice 2013 or above, you can enable the PowerPivot Addin in File >> Options, select COM-addin and then Go, and then use the additional functions in the PowerPivot module for your needs.

https://support.office.com/en-us/article/start-the-power-pivot-add-in-for-excel-a891a66d-36e3-43fc-81e8-fc4798f39ea8

After enabling Powerpivot addin, you can create a new measure MaxItem1 using the maxx(datatable, datatable[item1]). then you can use this MaxItem1 measure to do sum(). You may need to use sumx(datatable, datatable[MaxItem1]+datatable[MaxItem2]).

Similarly minx() can be used to create MinItem values.

You may refer to this 5-min video for how to operate in Powerpivot. This video is not actually using the sum() function. You can look into sumx() to craft that precise function as above, which is not hard.

https://www.youtube.com/watch?v=lE2OAPh-Zf8

(I dont know if quoting video is allow or not in this forum, any moderater please correct me if I did something wrong. Unfortunately the excel I am using is 2010 at the moment, and I cannot create a XLS file for you to refer to directly. But I suppose the video is pretty clear and it is very easy to do.)

2
  • Great, thanks. I'm surprised it isn't possible with basic PivotTables, but at least I wasn't just missing something simple!
    – gisol
    Apr 22, 2020 at 8:24
  • You are welcome! Good to know it helps, and thanks for your upvote.
    – Bu Luno
    Apr 23, 2020 at 4:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .