Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Nemanja
Contributor
Contributor

Script load on a condition from another table column value

Hi guys, I was wondering if you could help me with something that I need to develop.

I have several straight loads from csv files, which have the same structure,

and one of the differences between them is the country value.

Example:

//Mexico load:

FlatFile:
LOAD
*
FROM [lib://data/Mexico_$(vMonthToLoad)$(vYearToLoad).csv]
(txt, codepage is 28591, embedded labels, delimiter is ',', msq)
;

//Australia load:

FlatFile:
LOAD
*
FROM [lib://data/Australia_$(vMonthToLoad)$(vYearToLoad).csv]
(txt, codepage is 28591, embedded labels, delimiter is ',', msq)
;

After the successful load, I save the results of the load as successTable in qvd with the structure:

Country | Status | Month | Year
Mexico | Success |Oct | 2021
Australia | Success |Oct | 2021
Malta | Failure | Oct | 2021

How would I make the script to execute the load only for country "Malta"

if the script for Malta is following the same structure as the loads before:

//Malta load:

FlatFile:
LOAD
*
FROM [lib://data/Malta_$(vMonthToLoad)$(vYearToLoad).csv]
(txt, codepage is 28591, embedded labels, delimiter is ',', msq)
;

I was thinking something along the way of Peek() and to make some kind of loop, but I was hopping that you can point me in right direction 😄

Thanks

Labels (1)
  • SaaS

2 Replies
Lisa_P
Employee
Employee

You could add the Country into the script as a field using:

//Mexico load:

FlatFile:
LOAD
*,

'Mexico' as Country
FROM [lib://data/Mexico_$(vMonthToLoad)$(vYearToLoad).csv]
(txt, codepage is 28591, embedded labels, delimiter is ',', msq)
;

//Australia load:

FlatFile:
LOAD
*,

'Australia' as Country
FROM [lib://data/Australia_$(vMonthToLoad)$(vYearToLoad).csv]
(txt, codepage is 28591, embedded labels, delimiter is ',', msq)
;

 

//Malta load:

FlatFile:
LOAD
*,

'Malta' as Country
FROM [lib://data/Malta_$(vMonthToLoad)$(vYearToLoad).csv]
(txt, codepage is 28591, embedded labels, delimiter is ',', msq)
;

 

Then to create a QVD with only Malta at that as a condition in the Store statement:

STORE successTable into .....

Where Country='Malta';

 

Nemanja
Contributor
Contributor
Author

Hi,

Thank you, but I want to have the results from success table determine which part of script should execute. In this case, I would like to execute only Malta part, and to skip the rest.

So to run only parts where status is failure