To illustrate the problem, consider the following data: 1,2,3,5,3,2
. Enter this in a spreadsheet column and make a pivot table displaying the counts. Making use of the information in this pivot table, I want to create a new table, with counts for every value between 1 and 5.
1,1
2,2
3,2
4,0
5,1
What is a good way to do this? My first thought was to use VLOOKUP
, trapping any lookup error. But GETPIVOTDATA
is apparently preferred for pivot tables. In any case, I failed with both approaches.
To be a bit more specific, assume my pivot table of counts is "PivotTable1" and that I have already created a one column table holding all the needed lookup keys (i.e., the numbers from 1 to 5). What formula should I put in the second column of this new table?
If performance is not a major concern, you can bypass the pivot table and use the
COUNTIF()
function.Create a list of all consecutive numbers that you want the counts for and use
COUNTIF()
for each of them with the first parameter being the range of your input numbers and the second being the number of the ordered result list:So starting with this:
I then created the table like this:
Or, in A1 mode:
The column
X
in my summary table is in columnF
.Or as a table formula:
That gave me this result: