Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Getting invalid Expression when using multiple IF condition

Hi ,

Original Code:

load [ID], if(max(isDraft)=1 and min(isDraft)=0, 2, if( max(isDraft) <2, 1, max(isDraft)) ) as docMaxPublishedVersion,

if(max(isDraft)=1 and min(isDraft)=0 , 1, 0 ) as oneDraftOnePublish

resident AdminDoc

Modified Code:

load [docID], if(max(isDraft)=1 and min(isDraft)=0, 2, if( max(isDraft) <2,1,if(DocIsDeleted = 1 ,Version,max(isDraft))) ) as docMaxPublishedVersion,

if(max(isDraft)=1 and min(isDraft)=0 , 1, 0 ) as oneDraftOnePublish

resident AdminDoc

We have added one more condition to the Original Code( i.e DocIsDeleted ), adding this if condition in Modified Code, results in INVALID EXPRESSION.

Also tried ISNULL , got same error.

please advice.

thanks in advance

Tags (2)
1 Solution

Accepted Solutions

Re: Getting invalid Expression when using multiple IF condition

Your load is an aggregation load which needs an group by statement - have you DocIsDeleted added to them?


- Marcus

7 Replies

Re: Getting invalid Expression when using multiple IF condition

Your load is an aggregation load which needs an group by statement - have you DocIsDeleted added to them?


- Marcus

manojkulkarni
Valued Contributor II

Re: Getting invalid Expression when using multiple IF condition

could you post your application..

MVP
MVP

Re: Getting invalid Expression when using multiple IF condition

Does the LOAD have a Group By clause? Check that all of the non-aggregated fields (eg docID) are in the group by, and none of the aggregated fields are.

i suspect that DocIsdeleted is not in the GROUP BY.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

Re: Getting invalid Expression when using multiple IF condition

thanks,

load [docID], if(max(isDraft)=1 and min(isDraft)=0, 2, if( max(isDraft) <2,1,if(DocIsDeleted = 1 ,Version,max(isDraft))) ) as docMaxPublishedVersion,

if(max(isDraft)=1 and min(isDraft)=0 , 1, 0 ) as oneDraftOnePublish

resident AdminDoc

group by [docID].

this is what the code is, so i need to add the DocIsDeleted  to the group by so it looks like

group by [docID],DocIsDeleted  ?

tried the above did not work.

correct me ,if am wrong

Not applicable

Re: Getting invalid Expression when using multiple IF condition

thanks,

i suspect that DocIsdeleted is not in the GROUP BY.?

you are right, but after adding also i see the same error


Not applicable

Re: Getting invalid Expression when using multiple IF condition

Thanks all,

it worked ,as i added another field Version into the Group By.

i would also like to know what is aggregation load. please explain.

thanks again.

Re: Getting invalid Expression when using multiple IF condition

Each time if you used expressions like max/min/avg/sum/concat you made an aggregation load which will be grouped on these fields which are not included in the above mentioned expressions and which will be need to call explicit in these group by statement.

- Marcus

Community Browser