Reply
   
 Formula Help for Numbers - IF statements & counting 
 
 
  #1 (permalink)  
Old 17-06-2008, 12:25 PM
Beware the Robot Mafia

Group: Administrators
Location: St. Albans, Melbourne
Blog Entries: 11


Formula Help for Numbers - IF statements & counting

I've got a column of different options, say 1, 2, 3, 4, 5 - how can I get it to count how many times a certain string appears in the data set (the column)?

e.g: count how many times "item x" appears column A then print number, count how many times "item y" appears in column A then print number, count how many times "item z" appears in column A then print number etc.
__________________
Support MacTalk by shopping the Apple Online store via this link!
HEY INTERNET! - My Internet scrapbook.
TechieTalk - My 2c on Australian Tech News.
DMG Control Mac Apps - One More Thing Hardware Reviews - Can Touch This iPhone Apps
decryption is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #2 (permalink)  
Old 17-06-2008, 12:32 PM
Regular

Group: Regulars
Location: Brisbane


This is clunky, but could you create another set of columns and use IF, THEN to assign 1 or 0 to the result (i.e. if A1 has data of response 1, then if A1=1 then C1 = 1, then tally up the C column as only the ones will get a value of 1 assigned, you could then go on and do it for A1 data response 2 for column D etc)...

I know what I mean, does this make sense?

It's not pretty but I've done it before for stuff like this (I asked a similar question on here earlier this year)...

I'm sure there are better ways of doing it, but this is how I managed in my non-technologically advanced way....
__________________
Successful Trades: krazy1, Astr0b0y, soulman, areal, smdnetau, Huy, Alessiman, step_andy, tibook, mulquemi, BoxDog, Devski, The Keddi, decryption
Rasta is offline
Profile CardPM
Go to the top of the page
Reply With Quote
Huy
  #3 (permalink)  
Old 17-06-2008, 12:34 PM
It's a cruel, cruel summer

Group: Regulars
Location: NSW


If it was me I would sort column A, B, C, D, E (corresponding to 1-5) in ascending order (or descending it doesn't matter).

Then I would use a COUNT for the rows where the cells differ.

e.g.
COLUMN A (sorted in descending)
X
X
X

Y
Y

Z

=COUNT(A2:A4) -- for the total of X's (3)
=COUNT(A5:A6) -- for Y's (2)
=COUNT(A7) -- for Z's (1)

Of course this is a small data set but you can expand it for bigger ones and just look at the beginning and end cells for the references.

Hope that helps,
Huy is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #4 (permalink)  
Old 17-06-2008, 12:39 PM
MacTalk Donor

Group: Regulars
Location: Melbourne


Countif
Sumif

I'm pretty sure they exist in Numbers (not using mac at present); they do what I think you want in Excel.
richbowen is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #5 (permalink)  
Old 17-06-2008, 12:44 PM
Beware the Robot Mafia

Group: Administrators
Location: St. Albans, Melbourne
Blog Entries: 11


Quote:
Originally Posted by Rasta View Post
This is clunky, but could you create another set of columns and use IF, THEN to assign 1 or 0 to the result (i.e. if A1 has data of response 1, then if A1=1 then C1 = 1, then tally up the C column as only the ones will get a value of 1 assigned, you could then go on and do it for A1 data response 2 for column D etc)...

I know what I mean, does this make sense?

It's not pretty but I've done it before for stuff like this (I asked a similar question on here earlier this year)...

I'm sure there are better ways of doing it, but this is how I managed in my non-technologically advanced way....
So an IF statement like IF A6="x" THEN B6="1" IF A6="y" THEN C6="1" then add up each column?

Quote:
Originally Posted by Huy View Post
If it was me I would sort column A, B, C, D, E (corresponding to 1-5) in ascending order (or descending it doesn't matter).

Then I would use a COUNT for the rows where the cells differ.

e.g.
COLUMN A (sorted in descending)
X
X
X

Y
Y

Z

=COUNT(A2:A4) -- for the total of X's (3)
=COUNT(A5:A6) -- for Y's (2)
=COUNT(A7) -- for Z's (1)

Of course this is a small data set but you can expand it for bigger ones and just look at the beginning and end cells for the references.

Hope that helps,
Hmm, I tried this - but the answer is always 0 for some reason
e.g: =COUNT(G2:G15) just results in 0 (the values in the cells are mixed text and numbers)
(btw, love the effort put into the colours, haha)
__________________
Support MacTalk by shopping the Apple Online store via this link!
HEY INTERNET! - My Internet scrapbook.
TechieTalk - My 2c on Australian Tech News.
DMG Control Mac Apps - One More Thing Hardware Reviews - Can Touch This iPhone Apps
decryption is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #6 (permalink)  
Old 17-06-2008, 12:52 PM
Regular

Group: Regulars
Location: Brisbane


Here is the post I posted in March this year trying to do what you're suggesting, it was with Excel, but I assume Numbers would be similar

Excel Guru's Help Needed
__________________
Successful Trades: krazy1, Astr0b0y, soulman, areal, smdnetau, Huy, Alessiman, step_andy, tibook, mulquemi, BoxDog, Devski, The Keddi, decryption
Rasta is offline
Profile CardPM
Go to the top of the page
Reply With Quote
Huy
  #7 (permalink)  
Old 17-06-2008, 12:54 PM
It's a cruel, cruel summer

Group: Regulars
Location: NSW


Try

=COUNTIF(A1:A6, "x")
=COUNTIF(A1:A6, "y")
=COUNTIF(A1:A6, "z")


where the A1:A6 represents the ENTIRE range and x, y, z represent the individual differences (different values).

That works for me in Excel and results in 3, 2, 1 in my above data set.
Huy is offline
Profile CardPM
Go to the top of the page
Reply With Quote
  #8 (permalink)  
Old 17-06-2008, 12:58 PM
Beware the Robot Mafia

Group: Administrators
Location: St. Albans, Melbourne
Blog Entries: 11


Quote:
Originally Posted by Huy View Post
Try

=COUNTIF(A1:A6, "x")
=COUNTIF(A1:A6, "y")
=COUNTIF(A1:A6, "z")


where the A1:A6 represents the ENTIRE range and x, y, z represent the individual differences (different values).

That works for me in Excel and results in 3, 2, 1 in my above data set.
w00t - works just the way I want it! Thanks
__________________
Support MacTalk by shopping the Apple Online store via this link!
HEY INTERNET! - My Internet scrapbook.
TechieTalk - My 2c on Australian Tech News.
DMG Control Mac Apps - One More Thing Hardware Reviews - Can Touch This iPhone Apps
decryption is offline
Profile CardPM
Go to the top of the page
Reply With Quote
 
Reply

Thread Tools

 
Similar Threads
 
Thread Thread Starter Forum Replies Last Post
Counting the number of times my app has been opened. rickyd Projects: Audio, Graphics, Video, HTPC and Programming 22 16-04-2008 10:15 PM
Co-Host wanted Formula 1 Podcast Ozracingwrap Projects: Audio, Graphics, Video, HTPC and Programming 16 05-03-2006 12:04 AM
Excel formula help needed step_andy Mac OS X & All Software 5 21-02-2006 04:24 PM