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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load data condition

Hello community,

I load data from several csv files also containing this data:

 

ArtikelnummerWarengruppe
123456997
1234573
1234585
1234594
1234604
123461997
1234621

Warengruppe '997' is invalid, so I have to replace all Artikelnummer containing '997' by a Warengruppe from another csv file. This file contains only Artikelnummer that are '997' and the 'new' Warengruppe.

For example:

 

ArtikelnummerWarengruppe
1234562
1234613

Tried several things with add load, replace load, not exists, exists but couldn't find a solution:

Replace Load

Artikelnummer,

Warengruppe

FROM

AlteArtikelWarengruppen.csv

(txt, codepage is 1252, embedded labels, delimiter is ';', msq)

where Warengruppe = 997;

Must have a knot in my thinking, but i basically erase all Warengruppe that are not contained in that file.

Please help! Thank you in advance.

13 Replies
Not applicable
Author

Error message tells me, i have a circular reference...

Some sample data as required, please be aware that the csv files contain thousands of rows each:

vk2009.csv
ArtikelnummerWarengruppe
10856601
10856601
10856601
10856601
10856601
1085750
1092740
10970180
10998451
11002430
1107528
1107528
11878997
1196328
1198928
1198928
1203528
12104452
12105172
12105172
1210693
12109472
12109472
121093
121093
12110103
1211010
12110103
1211010
1211010

vk2010.csv
ArtikelnummerWarengruppe
10856601
10856601
10856601
10856601
10856601
10856601
10856601
10856601
10856601
10856601
10856601
10856601
10856601
13292270
13419270
13946997
14023700
14023700
14025700
14025700
14025700
14025700
14025700
14028351
10749601
10749601
10856601
1138428
1138428

AlteArtikelWarengruppen.csv
ArtikelnummerWarengruppe
11861277
11862277
11863212
11864391
11866271
11867277
11869361
11872301
11875361
11876211
11877212
11878301
11880142
11881140
11882140
11885211
11892311
11893311
11894475
11908351
11915361
11917351
11918361
11919361
11920105
11921210
11922210
13723471
13724471
13744271
13842155
13843155
13946272
14450997
20009277
20012351
20013351
20014351
20015351
20016351
20017351

Forgot to add that, I import the data from the yearly csv files with join load. Does this work for you?

MarcoWedel

Hallo,

one solution could be then:

QlikCommunity_Thread_145610_Pic1.JPG

mapAlteArtikelWarengruppen:

Mapping LOAD

    Artikelnummer,

    Warengruppe

FROM AlteArtikelWarengruppen.csv (txt, codepage is 1252, embedded labels, delimiter is ';', msq);

tabArtikel:

LOAD Artikelnummer,

     If(Warengruppe = 997, ApplyMap('mapAlteArtikelWarengruppen', Artikelnummer), Warengruppe) as Warengruppe,

     SubField(FileBaseName(),'vk',2) as vkJahr

FROM vk*.csv (txt, codepage is 1252, embedded labels, delimiter is ';', msq);

hope this helps

Gruß

Marco

Not applicable
Author

Hello Massimo,

I was trying your suggestion today which looks promising but didn't bring me the desired result.

Included my Code and some sample data.

    AAW:

    Load Artikelnummer, Warengruppe as Warengruppe2

    FROM [AlteArtikelWarengruppen.csv] (txt, codepage is 1252, embedded labels, delimiter is ';', msq); 

   

    tabVK:

    LOAD

     Left(Belegdatum, 4) as Jahr,

     Mid(Belegdatum, 5, 2) as Monat,

     Artikelnummer,

     Lieferschein,

     Warengruppe, 

     Kostenträger,

     If(Buchungscode > '20',Menge,If(Buchungscode < '19',Menge*(-1))) as Menge,

     [Name-1],

     Land,

     Artikelbezeichnung,

     Vertretername,

     If(Buchungscode > '20',(((Preis/[Preis per])*(1-([Kopfrabatt]/100))*(1-([Rabatt-1]/100))*(1-([Rabatt-2]/100)))*Menge),If(Buchungscode < '19',(((Preis*(-1)/[Preis per])*(1-([Kopfrabatt]/100))*(1-([Rabatt-1]/100))*(1-([Rabatt-2]/100)))*Menge))) as Umsatz,

     IF(Buchungscode > '20',(((Preis/[Preis per])*(1-([Kopfrabatt]/100))*(1-([Rabatt-1]/100))*(1-([Rabatt-2]/100)))*Menge)-((Einstandspreis/[Preis per])*Menge),If(Buchungscode < '19',(((Preis*(-1)/[Preis per])*(1-([Kopfrabatt]/100))*(1-([Rabatt-1]/100))*(1-([Rabatt-2]/100)))*Menge)-((Einstandspreis/[Preis per])*Menge*-1))) as Bruttodeckungsbeitrag

    FROM [vk*.csv] (txt, codepage is 1252, embedded labels, delimiter is ';', msq) where Artikelnummer <> '14001'; 

    Left Join (tabVK) 

    Load Artikelnummer, 997 as Warengruppe, Warengruppe2;

   

   

    final:

    NoConcatenate

    Load Artikelnummer, alt(Warengruppe2, Warengruppe) as Warengruppe

    Resident tabVK;

JOIN LOAD Kundenname as [Name-1],

     Kundengruppe

FROM

[Kundengruppen.csv]

(txt, codepage is 1252, embedded labels, delimiter is ';', msq);

You might find the mistake, that I couldn't find...

Thank you very much for your support!

Not applicable
Author

Hallo Marco,

I tried quite some variations of your solution, but still didn't manage do remove the circular reference and thus couldn't make it work...

I left the subfield reference away as i don't need the difference associated with the year I thought having: Artikelnummer, Warengruppe old, and Warengruppe new if Warengruppe old = 997

would be enough, but I still get all Warengruppen for each Article...

Gruss zurück,

Pascal