Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

frequency formula

ResolvedVersion 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?

Edited on Wed 10 Aug 2016, 16:07

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

Excel tip:

Hiding a worksheet in Excel

Want to circulate an Excel workbook file but keep certain worksheets hidden from your colleagues' view?

You can do so by bringing up the sheet you wish to hide on your screen; then going to Format - Sheet - Hide.

It will not be immediately obvious that a sheet is hidden from view unless perhaps the sheet are still labelled Sheet 1, Sheet 2 etc.

To display the sheet again, you can go to Format - Sheet - Unhide on any of the other sheets in the workbook. A dialogue box will appear, allowing you to select the hidden sheet/s. Click OK to make the sheet/s reappear again.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.