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: 
hudam
Contributor II
Contributor II

While Loop

On a call log, I am trying to count the number of calls it takes to make 'human contact'.  There is a contact_id field that groups the calls to a single individual. One individual will have one contact_id and each contact_id can have multiples rows (calls). 

Human contact is establish by the field 'contacted' being populated.

I am trying to us a while loop in the load editor to obtain these results.  I want to have a counter variable that will stop counting once we have identified the first 'contacted' field that is populated for each contact_id.   Here is some syntax for further clarity.

 

let ct = 0;

while (isnull(contacted) = -1)

ct = ct + 1 ;

loop

Load
'$(ct)' as numOfCalls;



I am unsure how to fit this logic into the Load script to obtain my desired results.  Any guidance or direction would be appreciated. 





Labels (1)
  • SaaS

1 Solution

Accepted Solutions
MarcoWedel

I don't think you need to loop over field values of a table like this. There should be shorter and better performing solutions.

Can you please provide some different examples and your expected results?

View solution in original post

2 Replies
MarcoWedel

I don't think you need to loop over field values of a table like this. There should be shorter and better performing solutions.

Can you please provide some different examples and your expected results?

hudam
Contributor II
Contributor II
Author

I was seeking an alternative method due to a bug I was having in my preferred solution. I am still learning SQL some and was not entirely sure how I could mix loops and control statements in with a select statement, if at all.

I have since then resolved said bug, and have been advised thanks to you. 

As for your response, thank you, you answered my question.