Simplicty and flexibility!


How do I do a count of the number of yes's in yes/no fields


Started by Simon Lazarus
Search
You will need to Sign In to be able to add or comment on the forum!

How do I do a count of the number of yes's in yes/no fields

Written by Simon Lazarus 01/05/20 at 13:13:05 LegEasy DOS

Re:How do I do a count of the number of yes's in yes/no fields

Depends a little where you want to count it.

You use a relationship.

in DQL you can do

retval := Count of MyTable with FieldX=Yes .

If you are to do this in a virtual field you need to define a relationship it can be between the Yes/No field so if it say YES you will get the count of yeses or if it say No you can get the number of Nos.

If it is always to be yes, you need to define a support field that is always yes and use that on one side of the relationship.


Written by DataEase 01/05/20 at 13:22:09 LegEasy DOS

Re:Re:How do I do a count of the number of yes's in yes/no fields

Thanks for the prompt response.

This works fine for a virtual field when I have added the support field to the relationship.

I am trying to compile responses from surveys and have 20 different fields i need to have individual yes totals on i a summary form


Written by Simon Lazarus 01/05/20 at 13:38:55 LegEasy DOS

Re:Re:Re:How do I do a count of the number of yes's in yes/no fields

Then you need 20 relationships if you are doing this in the form.

The support field can be used in all the relationships and then the other side is the individual fields.

You obviously have to use alternate relationship names.


Written by DataEase 01/05/20 at 17:20:18 LegEasy DOS

Re:Re:Re:Re:How do I do a count of the number of yes's in yes/no fields

Alternative relationship names works great - Thanks


Written by Simon Lazarus 04/05/20 at 13:07:53 LegEasy DOS

Re:Re:Re:Re:Re:How do I do a count of the number of yes's in yes/no fields

20 relationships is 'ugly' and the counting can be slow if you have a lot of records...

I would create a hidden integer field with a derivation of 'if( fieldname01 = 'yes', 1 , 0 ) for each of the 20 fields.

Then just do a 'sum of tablename fieldname01'

Only 1 relationship needed


Written by Earl Wertheimer 05/05/20 at 20:29:59 LegEasy DOS
DG3_ForumList