Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello all,
Happy Friday! Could someone please explain how can I use Count function in a variable. For example, I want to count the number of questions where Answer=Yes + Answer=No/Total Answer in percentage. Something like below.
vTotal=Count(Answer=Yes+No)/Count(Answers), #.##%
I tried below in the load script but it may not have worked because with
SET vTotal=count({<Answer={'Yes', 'No'}> Answers}/count(Answer)
It didn't work...perhaps set analysis syntax cannot be used in load script.
Any help is appreciated.
Hi,
You can try this at script lever as
Table1:
load count(if(Answer='YES'or Answer='NO',1,0))/Count(Answer) as x
from xxx
group by Answer;
vTotal=peek('x',-1,'Table1');
That's right, set analysis cannot be used in the script. But creating a variable with a set analysis expression will work fine. But make sure to use the exact case sensitive field names. Answers and Answer are two different field names. Perhaps you simply made a typo:
SET vTotal=count({<Answer={'Yes', 'No'}> Answers}/count(Answer)
Take a look at my example
Hi,
You can try this at script lever as
Table1:
load count(if(Answer='YES'or Answer='NO',1,0))/Count(Answer) as x
from xxx
group by Answer;
vTotal=peek('x',-1,'Table1');
Thanks Gysbert! Yes, it is a typo.
Thanks Reshma! Very useful.