Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
andreas_koehler
Creator II
Creator II

How to import such simple cross tables with shared fields?

Hi all,

this morning I wanted to import some simple forecast data: annual volumes and average prices of some products and some clients.

Turned out that I ended with a lot of attempts to manipulate tables, creating synthetic keys and still getting wrong results. Horrible.

I created a small example to illustrate the problem:

There are 3 clients and 2 products. Each combination has got a forecast of sales volume and price in 2 different crosstables.

I need to import this data with the fields Company, Product, Volume, Price and Year to match against real annual sales volume and price.

The sample data is inline. I also added an xlsx with same data. (I created the data.xlsx as I was wondering if there is an issue with applying crosstable to inline-data.)

The "Year" that is created using the crosstable and shared between both tables creates also a synthetic key. Interestingly I can not integrate the "Year" into my complex keys (even when I preload the data form the crosstable),

Any help is very much appreciated.

Andreas

1 Solution

Accepted Solutions
sunny_talwar

How about this?

VolumeForecast:

CrossTable(Year, Volume, 2)

LOAD Company,

    Product,

    [2016],

    [2017],

    [2018]

Resident ImportVolume;

PriceForecast:

CrossTable(Year, Price)

LOAD Company,

    Product,

    [2016],

    [2017],

    [2018]

Resident ImportVolume;

FinalTable:

NoConcatenate

LOAD *

Resident VolumeForecast;

Left Join (FinalTable)

LOAD *

Resident PriceForecast;

   

DROP Tables ImportVolume,ImportPrice, PriceForecast, VolumeForecast;

View solution in original post

2 Replies
andreas_koehler
Creator II
Creator II
Author

Rehi!

There is a small error in the statement that does not change the situation.

PriceForecast:

CrossTable(Year, Price, 2)

LOAD Company & '|' & Product as %Key,

     [2016],

     [2017],

     [2018]

/*FROM

[data.xlsx]

(ooxml, embedded labels, table is Price);

*/

resident ImportPrice;

sunny_talwar

How about this?

VolumeForecast:

CrossTable(Year, Volume, 2)

LOAD Company,

    Product,

    [2016],

    [2017],

    [2018]

Resident ImportVolume;

PriceForecast:

CrossTable(Year, Price)

LOAD Company,

    Product,

    [2016],

    [2017],

    [2018]

Resident ImportVolume;

FinalTable:

NoConcatenate

LOAD *

Resident VolumeForecast;

Left Join (FinalTable)

LOAD *

Resident PriceForecast;

   

DROP Tables ImportVolume,ImportPrice, PriceForecast, VolumeForecast;