Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
djbloiss
Contributor III
Contributor III

Extract text from long string

I am working on a QVD file to analyze NPrint logs.  I want something more detailed than any I have found.  The first thing I am trying to do is pull the task names into its own field.

This is what I am trying:

LET rowText = NoOfRows('tmpLogs'); // get the total number of rows in Timeline table

for i=1 to $(rowText) // loop through every row

    let CurrMessage = FieldValue(Message,$(i)); //get the value for "text" field on each row

    let PrevMessage = FieldValue(Message,$(i)-1);

    LogData:

    LOAD

        if(WildMatch($(CurrMessage), '*Run Task*'), mid($(CurrMessage),Index($(CurrMessage),'Run Task:')+1)) as TaskName

    resident tmpLogs;

next

It is crashing on the Wildmatch line.  What am I missing? It is saying Error in Expression: ')' expected but I cannot see any missing parenthesis in the line.

6 Replies
sunny_talwar

May be add single quotes around the variable

LET rowText = NoOfRows('tmpLogs'); // get the total number of rows in Timeline table

for i=1 to $(rowText) // loop through every row

    let CurrMessage = FieldValue(Message,$(i)); //get the value for "text" field on each row

    let PrevMessage = FieldValue(Message,$(i)-1);

    LogData:

    LOAD

        if(WildMatch('$(CurrMessage)', '*Run Task*'), mid('$(CurrMessage)',Index('$(CurrMessage)','Run Task:')+1)) as TaskName

    resident tmpLogs;

next

djbloiss
Contributor III
Contributor III
Author

Sunny,

now it is not longer crashing but it is not returning any values.  The Syntax looks correct and it is generating no errors.  Have any ideas?  This should work on any Nprint log file.

sunny_talwar

Would you be able to give 2-3 rows of lines to check this out?

djbloiss
Contributor III
Contributor III
Author

Application    7/23/2018    11:33:42 AM    Message    Run Task: Execute Sales Divisions Daily Update SchoolsApplication    7/23/2018    11:33:42 AM    Message    Run Task: Execute Sales Divisions Daily Update Schools

Application    7/23/2018    11:34:11 AM    Message    Open file: \\172.16.0.28\d$\Production\Max_Quality_Food_Data_Model_NewSource.qvw

Application    7/23/2018    11:35:03 AM    Information    QlikView version: 11.20.12451.0

Application    7/23/2018    11:35:04 AM    Message    Clear all selections: \\172.16.0.28\d$\Production\Max_Quality_Food_Data_Model_NewSource.qvw

Every line starts with Application

sunny_talwar

Got it... checking

sunny_talwar

Can you see if this works?

Table:

LOAD @1,

If(SubStringCount(@1, 'Run Task') > 1, SubField(@1, 'Run Task:', -1)) as TaskName

FROM

[..\..\Downloads\309546.txt]

(txt, codepage is 1252, explicit labels, delimiter is ';', msq);