Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
swuehl
MVP
MVP

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
Master
Master

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);

Anonymous
Not applicable
Author

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.