Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
qlikrajan
Contributor III

load existing field in table in subroutine

I have two excel files and these have field names invoice number and Invoice amount. Invoice amount is termed as amount in one file and Money in another file. I have written a subroutine to load both the excel files in qlikview and I want to specify "if field name is amount then load amount otherwise look for Money and load the existing field as Invoice amount". One file can have either field name amount or Money. I am not sure which function should be used in load script. FieldNumber function can't be used as it must not reference the table currently being loaded. I don't want to use ScriptError function.


file1
invoice numberamount
a1
b2
c3
d4


file2
invoice numberMoney
e12
f13
g14
h15


Any help is much appreciated.

3 Replies
MVP
MVP

Re: load existing field in table in subroutine

Maybe just load your tables, then finally do rename Money field to 'Invoice amount'

LOAD * from ...;

LOAD * from ...;

RENAME FIELD Money TO [Invoice amount];

effinty2112
Honored Contributor

Re: load existing field in table in subroutine

Hi,

This script will load both files creating the fieldnames [invoice number] and amount in the resulting resident table. The header is 1 lines qualifier ignores the excel headers and allows you to specify the headers you want for the two fields

Data:

LOAD A as [invoice number],

     B as amount

FROM

file1.xlsx // amend filename here or replace with *.xlsx to load both files from common directory

(ooxml, no labels, header is 1 lines, table is Sheet1);

qlikrajan
Contributor III

Re: load existing field in table in subroutine

Andrew- Unfortunately, the number of columns/fields are not the same and not in the same order in all the excel files so we can not use alpha/numeric (A / @1 as field name) references of field names. My bad, I should have specified this constraint.

Community Browser