Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression in load script (newbie question)

Hi

I'm new to Qlikview and i'm trying to put an expression in the load script for the 1st time and i can't work out why it's not working. Please could you help?

I am loading the following expression:

Transactions:

load *,

if ([Behavior Score Criteria] = 'Samples_Form_Lit_Request',if(count(Material_Name)>0 and count(litTitle)>0 and count(formTitle) >0 and ApprovalStatus='Approved',0,10)) as [Behaviour Score]

Anything obvious i'm doing wrong?

Thanks in advance.!

1 Solution

Accepted Solutions
Not applicable
Author

Hi Daniel,

you are using an aggregation function (count) without a corresponding group by clause It looks like.

Your code as it stands will be loaded row by row, so the count won't work.

Are you looking for a row by row evaluation to create that field? Or do you want to group it up and count?

If you want this row by row and you are just trying to check if the fields contain any value (rather than want a count), the below should work

if ([Behavior Score Criteria] = 'Samples_Form_Lit_Request',if(Len(Material_Name)>0 and Len(litTitle)>0 and Len(formTitle) >0 and ApprovalStatus='Approved',0,10)) as [Behaviour Score]

otherwise look to add a group by

hope that helps

Joe

View solution in original post

4 Replies
Not applicable
Author

Hi Daniel,

you are using an aggregation function (count) without a corresponding group by clause It looks like.

Your code as it stands will be loaded row by row, so the count won't work.

Are you looking for a row by row evaluation to create that field? Or do you want to group it up and count?

If you want this row by row and you are just trying to check if the fields contain any value (rather than want a count), the below should work

if ([Behavior Score Criteria] = 'Samples_Form_Lit_Request',if(Len(Material_Name)>0 and Len(litTitle)>0 and Len(formTitle) >0 and ApprovalStatus='Approved',0,10)) as [Behaviour Score]

otherwise look to add a group by

hope that helps

Joe

fkeuroglian
Partner - Master
Partner - Master

Hi, try this:

if ([Behavior Score Criteria] = 'Samples_Form_Lit_Request',if(Material_Name)>0 and litTitle>0 and formTitle >0 and ApprovalStatus='Approved',0,10)) as [Behaviour Score],


try to take out the count(field) IN THE EXPRESION IN THE SCRIPT


good luck


Fernando

Not applicable
Author

Thanks JoeSimmons!

I was looking for a row by row evaluation rather than a count, your method worked great.

Thanks very much!

Danny

Not applicable
Author

No worries, glad to help