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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
lockematthewp
Creator II
Creator II

Loop in Script Help

Spoiler
 

I currently have a table with a few fields including TotalDataPoints and BadDataPoint. For example, I might have TotalDataPoints as 10 and BadDataPoint values of 2,5, and 9. I would like to make a table with all values from 1 to TotalDataPoints (20 in this example) so I can make another two fields called DataPoint and ValidPoint. This would have 'Good' unless it is equal to BadDataPoint, in which case it would be equal to 'Bad'. 

Before:

TotalDataPointsBadDataPoint
102
105
109

 

After:

TotalDataPointsDataPointValidPoint
101Good
102Bad
103Good
104Good
105Bad
106Good
107Good
108Good
109Bad
1010Good
2 Replies
sunny_talwar

May be this

Table:
LOAD TotalDataPoints,
	 BadDataPoint as DatPoint,
	 'Bad' as ValidPoint;
LOAD * INLINE [
    TotalDataPoints, BadDataPoint
    10, 2
    10, 5
    10, 9
];

Concatenate (Table)
LOAD *
Where Not Exists(DatPoint);
LOAD Distinct TotalDataPoints,
	 IterNo() as DatPoint,
	 'Good' as ValidPoint
Resident Table
While IterNo() <= TotalDataPoints;
felcar2013
Partner - Creator III
Partner - Creator III

hi

try this

FOR vDataPoint= 1 to 10

tab:
Load *,
if(match(DataPoint,2,5,9),'Bad','Good') as ValidPoint
;
Load 10 as TotalDataPoint,
$(vDataPoint) as DataPoint
AutoGenerate 1
;


NEXT