Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need help with mapping

Hello,

I only recently started with qlikview and I need help with my mapping structure.

Now, I created unique dimentions and I have my main data gathered. Now in my main data I have the names of my dimentions and I want to swap these with the Id's through mapping. I've tried many things but I'm just a starter so I could use some help since it just won't work.

I've added all the files I use. Other advise is also appreciated!

Jens,

8 Replies
oknotsen
Master III
Master III

Hi,

Since you got a lot of code and (Dutch) text in there:

  • Can you specify which field in which table you want to use the mapping with and roughly where we can find it in your script?
  • Can you tell us which table you want to use for your mapping?

That will make it a lot easier for us to find the part that you have problems with.

May you live in interesting times!
Anonymous
Not applicable
Author

Hi Jens,

Please copy paste script here, i am using Personnal Edition.

Will be able to help.

Regards

Neetha

Not applicable
Author

I want the fact table in "Main Data" to have the Id's of "Plaats", "Verwonding", "Bebouwdekom" and "Jaar" instead of the name. If you click on the 2e tab, you see all the data but I need the Id's to be there instead of the names.

So the problem is I have "PlaatsId" in my fact table but it has the name and not the Id in it. I want to connect all 4 dimentions to the fact table with mapping so I receive the Id's for it.

Does this answer your question?

Not applicable
Author

This is my script, I only copied Main Data, Plaats (1 of the 4 dimentions) and my mapping tab. I hope this is enough?


Main Data:

/*

Naam:    Jens Leysen

Nr.:     r0258402

School:  Thomas More Geel

Omschrijving:

In deze 'Main Data' worden de 5 gebruikte tabellen van het excel bestand ingeladen.

De table Ongevallen wordt gedropt en er wordt gebruikt gemaakt van dimensies die aangemaakt zijn in de overige tabbladen.

De gegevens komen van http://data.gov.be/dataset/traffic-accidents.

Het gebruikte document is "accidents_dossier_2009_1nl_tcm325-33655.xls".

*/

Ongevallen:  // facttable een naam geven, namelijk "Ongevallen". Wordt gebruikt voor het opslaan (STORE) later.

CrossTable(Jaar, Aantal, 3)

LOAD [Evolutie van het aantal ongevallen per gewest binnen of buiten de bebouwde kom] AS PlaatsId,

  'Evolutie van het aantal ongevallen per gewest binnen of buiten de bebouwde kom' AS VerwondingId, // de verwonding die in verschillende tabbladen zit hier meegeven

     [Bebouwde kom] AS BebouwdekomId,

     [1997],

     [1998],

     [1999],

     [2000],

     [2001],

     [2002],

     [2005],

     [2006],

     [2007],

     [2008],

     [2009]

FROM

(biff, embedded labels, table is [Beb kom$], filters(

Remove(Row, Pos(Top, 1)),

Remove(Row, Pos(Top, 38)),

Remove(Row, Pos(Top, 37)),

Remove(Row, Pos(Top, 36)),

Remove(Row, Pos(Top, 35)),

Remove(Row, Pos(Top, 34)),

Remove(Row, Pos(Top, 33)),

Remove(Row, Pos(Top, 32)),

Remove(Row, Pos(Top, 31)),

Remove(Row, Pos(Top, 30)),

Remove(Row, Pos(Top, 29)),

Remove(Row, Pos(Top, 28)),

Remove(Row, Pos(Top, 27)),

Remove(Row, Pos(Top, 26)),

Remove(Row, Pos(Top, 25)),

Remove(Row, Pos(Top, 24)),

Remove(Row, Pos(Top, 23)),

Remove(Row, Pos(Top, 22)),

Remove(Row, Pos(Top, 21)),

Remove(Row, Pos(Top, 20)),

Remove(Row, Pos(Top, 19)),

Replace(1, top, StrCnd(null)),

Remove(Row, Pos(Top, 1))

));

CrossTable(Jaar, Aantal, 3)

LOAD [Evolutie van het aantal slachtoffers per gewest binnen of buiten de bebouwde kom] AS PlaatsId,

  'Evolutie van het aantal slachtoffers per gewest binnen of buiten de bebouwde kom' AS VerwondingId, // de verwonding die in verschillende tabbladen zit hier meegeven

     [Bebouwde kom] AS BebouwdekomId,

     [1997],

     [1998],

     [1999],

     [2000],

     [2001],

     [2002],

     [2005],

     [2006],

     [2007],

     [2008],

     [2009]

FROM

(biff, embedded labels, table is [Beb kom$], filters(

Remove(Row, Pos(Top, 1)),

Remove(Row, Pos(Top, 19)),

Remove(Row, Pos(Top, 18)),

Remove(Row, Pos(Top, 17)),

Remove(Row, Pos(Top, 16)),

Remove(Row, Pos(Top, 15)),

Remove(Row, Pos(Top, 14)),

Remove(Row, Pos(Top, 13)),

Remove(Row, Pos(Top, 12)),

Remove(Row, Pos(Top, 11)),

Remove(Row, Pos(Top, 10)),

Remove(Row, Pos(Top, 9)),

Remove(Row, Pos(Top, 8)),

Remove(Row, Pos(Top, 7)),

Remove(Row, Pos(Top, 6)),

Remove(Row, Pos(Top, 5)),

Remove(Row, Pos(Top, 4)),

Remove(Row, Pos(Top, 3)),

Remove(Row, Pos(Top, 2)),

Remove(Row, Pos(Top, 1)),

Remove(Row, Pos(Top, 19)),

Replace(1, top, StrCnd(null)),

Remove(Row, Pos(Top, 1))

));

CrossTable(Jaar, Aantal, 3)

LOAD [Evolutie van het aantal doden en dodelijk gewonden (doden 30 dagen) per gewest binnen of buiten de bebouwde kom] AS PlaatsId,

  'Evolutie van het aantal doden en dodelijk gewonden (doden 30 dagen) per gewest binnen of buiten de bebouwde kom' AS VerwondingId, // de verwonding die in verschillende tabbladen zit hier meegeven

     [Bebouwde kom] AS BebouwdekomId,

     [1997],

     [1998],

     [1999],

     [2000],

     [2001],

     [2002],

     [2005],

     [2006],

     [2007],

     [2008],

     [2009]

FROM

(biff, embedded labels, table is [Beb kom vervolg$], filters(

Remove(Row, Pos(Top, 1)),

Remove(Row, Pos(Top, 38)),

Remove(Row, Pos(Top, 37)),

Remove(Row, Pos(Top, 36)),

Remove(Row, Pos(Top, 35)),

Remove(Row, Pos(Top, 34)),

Remove(Row, Pos(Top, 33)),

Remove(Row, Pos(Top, 32)),

Remove(Row, Pos(Top, 31)),

Remove(Row, Pos(Top, 30)),

Remove(Row, Pos(Top, 29)),

Remove(Row, Pos(Top, 28)),

Remove(Row, Pos(Top, 27)),

Remove(Row, Pos(Top, 26)),

Remove(Row, Pos(Top, 25)),

Remove(Row, Pos(Top, 24)),

Remove(Row, Pos(Top, 23)),

Remove(Row, Pos(Top, 22)),

Remove(Row, Pos(Top, 21)),

Remove(Row, Pos(Top, 20)),

Remove(Row, Pos(Top, 19)),

Replace(1, top, StrCnd(null)),

Remove(Row, Pos(Top, 1))

));

CrossTable(Jaar, Aantal, 3)

LOAD [Evolutie van het aantal zwaargewonden per gewest binnen of buiten de bebouwde kom] AS PlaatsId,

  'Evolutie van het aantal zwaargewonden per gewest binnen of buiten de bebouwde kom' AS VerwondingId, // de verwonding die in verschillende tabbladen zit hier meegeven

     [Bebouwde kom] AS BebouwdekomId,

     [1997],

     [1998],

     [1999],

     [2000],

     [2001],

     [2002],

     [2005],

     [2006],

     [2007],

     [2008],

     [2009]

FROM

(biff, embedded labels, table is [Beb kom vervolg$], filters(

Remove(Row, Pos(Top, 39)),

Remove(Row, Pos(Top, 20)),

Remove(Row, Pos(Top, 19)),

Remove(Row, Pos(Top, 18)),

Remove(Row, Pos(Top, 17)),

Remove(Row, Pos(Top, 16)),

Remove(Row, Pos(Top, 15)),

Remove(Row, Pos(Top, 14)),

Remove(Row, Pos(Top, 13)),

Remove(Row, Pos(Top, 12)),

Remove(Row, Pos(Top, 11)),

Remove(Row, Pos(Top, 10)),

Remove(Row, Pos(Top, 9)),

Remove(Row, Pos(Top, 8)),

Remove(Row, Pos(Top, 7)),

Remove(Row, Pos(Top, 6)),

Remove(Row, Pos(Top, 5)),

Remove(Row, Pos(Top, 4)),

Remove(Row, Pos(Top, 3)),

Remove(Row, Pos(Top, 2)),

Remove(Row, Pos(Top, 1)),

Replace(1, top, StrCnd(null)),

Remove(Row, Pos(Top, 1))

));

CrossTable(Jaar, Aantal, 3)

LOAD [Evolutie van het aantal licht gewonden per gewest binnen of buiten de bebouwde kom] AS PlaatsId,

  'Evolutie van het aantal licht gewonden per gewest binnen of buiten de bebouwde kom' AS VerwondingId, // de verwonding die in verschillende tabbladen zit hier meegeven

     [Bebouwde kom] AS BebouwdekomId,

     [1997],

     [1998],

     [1999],

     [2000],

     [2001],

     [2002],

     [2005],

     [2006],

     [2007],

     [2008],

     [2009]

FROM

(biff, embedded labels, table is [Beb kom vervolg2$], filters(

Remove(Row, Pos(Top, 1)),

Remove(Row, Pos(Top, 19)),

Replace(1, top, StrCnd(null)),

Remove(Row, Pos(Top, 1))

));

// Opslaan van de gegevens in een QVD file. Wordt gebruikt om de dimensies

STORE Ongevallen into 'C:\Users\Jens\Documents\1. SCHOOL\3TiB\3Ti Business Intelligence\Project\ongevallen.qvd' (qvd);

// Droppen van de tabellen van de facttable.

DROP Table Ongevallen;

// De dimensies uit de overige tabbladen inladen met correcte naamgeving.

LOAD PlaatsId, // ApplyMap('Map_Plaats', Plaats, 'Unknown Place') as PlaatsId,

     VerwondingId, // ApplyMap('Map_Verwonding', PurgeChar(Verwonding, Chr(10) & Chr(20)), 'Unknown'),//%VerwondingId,

     BebouwdekomId,

     Right(Jaar,2) as JaarId, // Functie voor het id en niet het jaar zelf te nemen.

     Aantal

FROM

(qvd);

Plaats:

/*

Naam:    Jens Leysen

Nr.:     r0258402

School:  Thomas More Geel

Omschrijving:

In dit tabblad wordt de dimensie Plaats uit de facttable 'Ongevallen' gehaald die in 'Main Data' wordt opgeslagen (STORE) als ongevallen.qvd.

We initialiseren ook een id.

We filteren zodat we slechts 1 plaats hebben met Distinct.

*/

Plaats:

LOAD Distinct AutoNumber(@1) as PlaatsId, // RowNo() as %PlaatsId,

  @1 as Plaats

FROM

(qvd, filters(

Remove(Col, Pos(Top, 5)),

Remove(Col, Pos(Top, 4)),

Remove(Col, Pos(Top, 3)),

Remove(Col, Pos(Top, 2)),

Replace(1, top, StrCnd(null))

));

STORE Plaats into 'C:\Users\Jens\Documents\1. SCHOOL\3TiB\3Ti Business Intelligence\Project\plaats.qvd' (qvd);

LOAD Distinct

PlaatsId,

Plaats

Resident Plaats;

Mapping:

Map_Plaats:

MAPPING LOAD Plaats,

PlaatsId

Resident Plaats;

Map_Verwonding:

MAPPING LOAD Verwonding,

VerwondingId

Resident Verwonding;

Map_Bebouwdekom:

MAPPING LOAD Bebouwdekom,

BebouwdekomId

Resident Bebouwdekom;

Map_Jaar:

MAPPING LOAD Jaar,

JaarId

Resident Jaar;

Not applicable
Author

It takes quite some time for admins to accept my replies, I'm sorry for the delay.

oknotsen
Master III
Master III

Jens Leysen wrote:

It takes quite some time for admins to accept my replies, I'm sorry for the delay.

That is actually done by moderators (like me) and those hardly work during the weekend (like me).

After you scored 100 points, not every post will go into moderation (only those triggering moderation). So check your points, check your missions and see if you can score a few (like getting an avatar, bookmark a bunch of posts, etc).

May you live in interesting times!
oknotsen
Master III
Master III

Please next time only post the relevant parts of your code instead of hundreds of lines.

Based on a quick scan (I am not going read hundreds of lines), I think your mappings are not working because you create your mapping tables at the END of your code.

As a best practice: Make a mapping tab as the 2nd tab of your code, put all the mapping tables there (if technically and functionally possible), so they are loaded in memory BEFORE you are trying to use them with your apply map function.

May you live in interesting times!
Not applicable
Author

I'm sorry, I didn't want to be rude.

I placed my mappings at the start and everything is working! Thanks a lot.