Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
kevbrown
Creator II
Creator II

New Column

I have 4 spreadsheets UnitA, B, C and D. If I load then into QV I don't know which Unit the data is from so would like to create a new column in the script called Unit that will populate the unit for that spreadsheet. How?

Thanks

1 Solution

Accepted Solutions
sunny_talwar

May be something like this:

Table:

LOAD AllYourFields,

          'Unit A' as Unit

FROM SpreadSheet1;

Concatenate(Table)

LOAD AllYourFields

          'Unit B' as Unit

FROM SpreadSheet2;

Concatenate(Table)

LOAD AllYourFields

          'Unit C' as Unit

FROM SpreadSheet3;

Concatenate(Table)

LOAD AllYourFields

          'Unit D' as Unit

FROM SpreadSheet4;

View solution in original post

9 Replies
MK_QSL
MVP
MVP

While Loading use FileName() as FileName..

kevbrown
Creator II
Creator II
Author

The filename isn't the Unit

sunny_talwar

Is the unit information available in the Excel or how else you would know when unit the data is in?

MK_QSL
MVP
MVP

is your units are file specific? I mean Unit A is coming from only one file, Unit B is also coming from 2nd file but not from 1st file...etc.

Anonymous
Not applicable

Kevin

Can you not just pass the name of the unit in your load script i.e. load 'Unit A' as Unit for each spreadsheet loaded

Kindest regards

Brian

kevbrown
Creator II
Creator II
Author

Yes, I pick up 4 spreadsheets from different locations for each of the 4 units. The spreadsheet all have the same name but are for different units.

sunny_talwar

May be something like this:

Table:

LOAD AllYourFields,

          'Unit A' as Unit

FROM SpreadSheet1;

Concatenate(Table)

LOAD AllYourFields

          'Unit B' as Unit

FROM SpreadSheet2;

Concatenate(Table)

LOAD AllYourFields

          'Unit C' as Unit

FROM SpreadSheet3;

Concatenate(Table)

LOAD AllYourFields

          'Unit D' as Unit

FROM SpreadSheet4;

jonathandienst
Partner - Champion III
Partner - Champion III

You can get the file path using FileName() and then map the path to the Unit using a mapping table and ApplyMap():

Map_units:

Mapping LOAD * Inline

[

     FilePath, Unit

     <.... path for unit 1 file ...>, Unit1

     <.... path for unit 2 file ...>, Unit2

      ...

];

Data:

LOAD .... <.. main load from spreadsheets ....>

     ApplyMap('Map_units', FileName()) As Unit,

     ...

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
kevbrown
Creator II
Creator II
Author

That's great, thanks