Ziphius Posted October 23, 2012 Posted October 23, 2012 I have 2 fields: Year (number), Skunks (Text: yes or no). I want to calculate the ratio of #skunks per year. I created the following summary field: sCountYear = sCount(Year) when sorted by Year sCountSkunks = sCount(Skunks) when sorted by Year I create a subsummary part when sorted by year to calculate the number of surveys done per year, and the number of skunks (no sightings) occurred each year. I need a summary field that will calculate the proportion of skunks per year for each year (sCountYear/sCountSkunks), but I can't make a summary field perform a calculation, and a calculation field isn't going to give me subsummary values by year, only a trailing grand summary. This must be really simple to do but I can't figure it out. Any help would be greatly appreciated.
comment Posted October 24, 2012 Posted October 24, 2012 To perform a calculation using sub-summary values, you need to use the GetSummary() function. Note. however, that a summary field will count all non-empty fields - so if your field contains either yes or no, all records will be counted alike. If, OTOH, you were using 1 for Yes, 0 (or empty) for No in a Number field, you could divide the sum of the field by the count to get the ratio.
Ziphius Posted October 24, 2012 Author Posted October 24, 2012 Correct, I oversimplified my example. The skunk field is actually a calculation field that sets a 1 if no sightings occurred and a 0 if at least one sighting occurred. The summary field is then a total of the skunk field as you have shown, not a count field. When I use the GetSummary function I can do: GetSummary (sTotalSkunks; cYear ) or GetSummary (sCountYear; cYear ) but what I want is: GetSummary (sTotalSkunks / sCountYear; cYear ) but I get the error: "Only summary fields are allowed as the first argument in a GetSummary function".
comment Posted October 24, 2012 Posted October 24, 2012 Try = GetSummary ( sTotalSkunks ; cYear ) / GetSummary ( sCountYear ; cYear ) You'll probably want to subtract that from 1, due to 0 being positive in your system. Note that the counting summary field can count any field that cannot be empty, and neither of the two summary fields needs to be running or restarting. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now