98.8% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel Training and help » Frequency Formula
Frequency Formula
Resolved · High Priority · Version 2010
John has attended:
Excel Advanced course
Frequency Formula
I have two sets of data. One column with reoccurring order numbers. eg. 123, 123, 123, 124, 124, 124. The other column with dates eg. 2015, 2016.
Using the FREQUENCY function I can calculate how many different order numbers appear in my first set of data. (ie. 2) but I am struggling to count the frequency when I want to split 2015 and 2016..
Any idea's on a function... maybe a nested IF?
RE: Frequency Formula
Hi John
Thanks for your question!
As you say the Frequency function can tally the number of occurrences of 123, 124, 125 etc. but not for multiple criteria such as 2015,2016.
There are other ways of achieving this but I can't at the moment see how with the Frequncy function. The first one is using the COUNTIFS function and the other is by creating a PivotTable.
1. With COUNTIFS
Suppose you have data as you suggested
Col A Col B
123 2015
123 2015
123 2016
124 2016
124 2015
125 2016
125 2016
125 2015
126 2016
123 2015
With the Countifs function you can create this summary
Col D Col E Col F
..... 2015 2016
123 3 1
124 1 1
125 1 2
126 0 1
The formula in E2 is
=COUNTIFS($A:$A,$D2,$B:$B,E$1)
It counts the number of times 123 AND 2015 occurs together. The $ signs are needed to allow copying of the formula down and across to E2:F5
2. By Pivot Table
First add some column heading eg Figs and Year
Figs Year
123 2015
123 2015
123 2016
124 2016
124 2015
125 2016
125 2016
125 2015
126 2016
123 2015
Select a cell in the data eg A1
Choose Insert, PivotTable, OK
In the field list drag Figs into ROWS labels
Year into COLUMNS
Figs into VALUES
Right click the pivot table, Value Field settings
Choose COUNT
Count of Figs Column Labels
Row Labels 2015 2016 Grand Total
123 3 1 4
124 1 1 2
125 1 2 3
126 1 1
Grand Total 5 5 10
This should give the same summary as with Countifs with added grand totals.
Hope that related to your question and helps for now.
Regards
Doug
STL
RE: Frequency Formula
I also tried this, but it didn't give me what I need. Let me try to explain in more detail
Col A
1
1
1
2
3
6
6
6
Col B
2015
2015
2015
2015
2016
2016
2016
2016
Repeated lines in Column A represent order numbers, and will always have the same year in Column B.
I want to know how many different order numbers there were in 2015 compared to 2016.
2015 = 3
2016 = 1
I cannot use the remove duplicates line as I have other information in my table.
RE: Frequency Formula
Hi again John
Thanks for clarifying. I've changed you example to match the output 2015 = 3, 2016 =1
Col A
1
1
1
2
3
6
6
6
Col B
2015
2015
2015
2015
2015
2016
2016
2016
Try this -
1. Click a cell within your data and choose Data, Remove Duplicates.
2. Un-tick column B and press OK.
The result I got was then
Col A
1
2
3
6
Col B
2015
2015
2015
2016
No you can use a formula =COUNTIF(B:B,"2015")
to tally the year counts.
So the trick is to un-tick the columns that contain other information apart from the order number.
Regards
Doug
RE: Frequency Formula
Doug,
Thank you for your help with this difficult problem.
Removing duplicates was the first thing I tried, and yes this method worked as you described. However, I have a big table of data with other columns which I am referencing. these are just the columns I need to formulate against. By removing duplicates, you remove all the information in that row. Removing rows will remove the other data lines I am using. I also refresh the data adding more lines regularly and don't want to keep reformatting the information.
Any other idea's
John
RE: Frequency Formula
Hi John
I understand now you don't want to delete any information.
Another approach might be Advanced filter. This has the same effect as remove duplicates but the filter can be removed. Works if the item numbers and dates are in adjacent columns.
To do this -
Select the range of cells containing your Item numbers and years (including the headings)
Choose Data, Advanced (under Sort & Group)
Select Copy to Another location
Check that the List range contains only the 2 columns of data for Item number and Data
Leave the criteria blank
Tick Unique records only
Choose a convenient cell to the right of your data for the destination (has to be on the active sheet)
Press ok
Then use Countif to count items for each year.
If I think of a neater way I will let you know.
Cheers
Doug
STL
Training information:
See also:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Deleting a range of cells using the autofill handleFirstly, select the range of cells for which you would like to clear the contents. Then drag the autofill handle to the the top left corner of the selection whilst holding down the shift key. Your selected contents should then be deleted. |