Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

expression in edit script

Hi everyone,

I am trying to achieve is " if any one 'Fail' occurs in an LensKey then the StatusField should be 'FAIL' "   and also see the attached script document.

I Used below line in edit script, it is not getting the correct result . Can you suggest the correct solution to get this.

if(sum([Status EdgeChips1])>=3,'Fail',if(sum([Status EdgeChips1])>=1,'Pass','NA')) as [Status EdgeChips]

The below is the sample example.

Ex1

LensKey, DefectStatus

1, Fail

1,Pass

1,-

For this ex1 , the result should be = Fail

Ex2:

LensKey, DefectStatus

2, Pass

2,Pass

2,-

For this ex2 , the result should be = Pass

Ex3

LensKey, DefectStatus

3,Fail

3,Fail

3,Fail

For this ex3 , the result should be = Fail

Ex4

LensKey, DefectStatus

4,-

4,-

4,-

For this ex4 , the result should be = NotAvailable.

Thanks in advance

1 Solution

Accepted Solutions
lkallioniemi
Partner - Contributor II
Partner - Contributor II

Hi,

have you tried max-function?

     left Join (Summarized)

     LOAD  LensKey,

     COUNT(CountDefectEdgeChip) as EdgeChipCountPerLens,

    if(max([Status EdgeChips1])=2,'Fail',if(max([Status EdgeChips1])=1,'Pass','NA')) as [Status EdgeChips]

     Resident Summarized

     Group by LensKey;

BR

Lasse

View solution in original post

5 Replies
Not applicable
Author

How about assigning a number to each type so that

LOAD

LensKey,

DefectStatus,

If(DefectStatus='Fail',5,If(DefectStatus='Pass,1,0)) as DefectValue

1 as Rec_Count

then in the display you can put logic in which says

If(sum(DefectValue>3,'Fail','Pass')  as DisplayValue

or if more than three records then

If(Sum(DefectValue)/sum(Rec_Count)>1'Fail','Pass')

hope this helps

lkallioniemi
Partner - Contributor II
Partner - Contributor II

Hi,

have you tried max-function?

     left Join (Summarized)

     LOAD  LensKey,

     COUNT(CountDefectEdgeChip) as EdgeChipCountPerLens,

    if(max([Status EdgeChips1])=2,'Fail',if(max([Status EdgeChips1])=1,'Pass','NA')) as [Status EdgeChips]

     Resident Summarized

     Group by LensKey;

BR

Lasse

Not applicable
Author

Hi Ikallioniemi,

Thanks you very much,

It was awesome, and works fine in my application.

Regards

Not applicable
Author

Hi ikallioniemi,

How can i count number of fails and pass in the each Lenskey.

If Pass or Fail is not available for particular LensKey, then it should display 0.

I need to place below to [Status EdgeChips], below code you provided for placing the 'Fail' or 'Pass'

left Join (Summarized)

     LOAD  LensKey,

     COUNT(CountDefectEdgeChip) as EdgeChipCountPerLens,

    if(max([Status EdgeChips1])=2,'Fail',if(max([Status EdgeChips1])=1,'Pass','NA')) as [Status EdgeChips],

//Here i need to place line for PassEdgeChips,

//Here i need to place line for FailEdgeChips

     Resident Summarized

     Group by LensKey;

Ex1

LensKey, DefectStatus

1, Fail

1,Pass

1,-

For this ex1 , the result should be PassEdgeChips=1, FailEdgeChips=1

Ex2:

LensKey, DefectStatus

2, Pass

2,Pass

2,-

For this ex2 , the result should be PassEdgeChips=2, FailEdgeChips=0

Ex3

LensKey, DefectStatus

3,Fail

3,Fail

3,Fail

For this ex3 , the result should be PassEdgeChips=0, FailEdgeChips=3

Ex4

LensKey, DefectStatus

4,-

4,-

4,-

For this ex4 , the result should be PassEdgeChips=0, FailEdgeChips=0

How can i work on this ?

Thanks in Advance.

lkallioniemi
Partner - Contributor II
Partner - Contributor II

Hi,

this should do the trick:

     Sum(if([Status EdgeChips1]=2,1,0))= as  FailEdgeChips,

       Sum(if([Status EdgeChips1]=1,1,0))= as PassEdgeChips,

BR

Lasse