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

do/for loop script needed?

Hi All,

Please help me implement below requirement.

Data looks like below

   

NumberSub-NumberStatus
11.1pass
1.2fail
11.3reject
22.1pass
22.5 pass
33.2fail
33.3fail
33.4reject

Requirement:

get the list of numbers for which, status is only 'pass' for all the Sub-Number.

to make it clear, if corresponding status for all the Sub-Numbers for a given Number is ''pass'', then only it should appear in output list.

so in above example, output list will contain only number 2.

please help.

any suggestion appreciated.

Thanks&Regard

Jyothi

1 Solution

Accepted Solutions
anbu1984
Master III
Master III

In Script,

T1:
Load * Inline [
Number,Sub-Number,Status
1,1.1,pass
1 ,1.2,fail
1,1.3,reject
2,2.1,pass
2,2.5,pass
3,3.2,fail
3,3.3,fail
3,3.4,reject ]
;

Load Number where IsStatusPass = 1;
Load Number,If(MaxString(Status)='pass' And MaxString(Status)=MinString(Status),1,0) As IsStatusPass Resident T1 Group By Number;

View solution in original post

11 Replies
maxgro
MVP
MVP

make a straight table chart with

dimension         

     Number

expression          

     if(Count(TOTAL <Number> Status) = Count({$ <Status={pass}>} TOTAL <Number> Status),1, 0)

anbu1984
Master III
Master III

In Script,

T1:
Load * Inline [
Number,Sub-Number,Status
1,1.1,pass
1 ,1.2,fail
1,1.3,reject
2,2.1,pass
2,2.5,pass
3,3.2,fail
3,3.3,fail
3,3.4,reject ]
;

Load Number where IsStatusPass = 1;
Load Number,If(MaxString(Status)='pass' And MaxString(Status)=MinString(Status),1,0) As IsStatusPass Resident T1 Group By Number;

Not applicable
Author

Hi Massimo,

Thanks for you suggestion. But requirement is to implement it in Script..

Anonymous
Not applicable
Author

Or this:

T1:
Load * Inline [
Number,Sub-Number,Status
1,1.1,pass
1 ,1.2,fail
1,1.3,reject
2,2.1,pass
2,2.5,pass
3,3.2,fail
3,3.3,fail
3,3.4,reject ]
;

Result:
LOAD Number where AllStatus='pass';
LOAD DISTINCT Number, concat(distinct Status) as AllStatus RESIDENT T1
GROUP BY Number;


DROP TABLE T1;

maxgro
MVP
MVP

in script,  if your table is T1

T2:

load Number, Status where Status = 'pass';

NoConcatenate load  Number, count(distinct Status), MaxString(Status) as Status

Resident T1 group by Number;

DROP Table T1;

Not applicable
Author

Perfect! This worked for me.

Thanks a lot Anbu.

Would you please explain your code? I m new to Qlikview so having trouble to understand..

anbu1984
Master III
Master III

If you have only Pass for a Number, then your MaxString and MinString of Status will be Pass and IsStatusPass is set to one. In Preceding load, where clause is used to get Numbers only have Pass as status

Load Number where IsStatusPass = 1; //Preceding Load

If(MaxString(Status)='pass' And MaxString(Status)=MinString(Status),1,0) As IsStatusPass


Not applicable
Author

Thanks Anbu!

Is it possible if i have to load many fields in the above script?

i tried adding one more field.. and i m getting Unknown Error.

could you please suggest?

Thanks

Jyothi.

anbu1984
Master III
Master III

Do you want to add another field along with Number? Then you should include the same in Group By clause

Can you post what you tried?