Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Not applicable

testing if a mapping table exists

Hi guys,

I need to test if a mapping table is loaded. usually for a "normal" table i'm using a test of NoOfRows() but with a mapping table it doesn't work... any idea.

I do have an ugly workaround :when I load the mapping table, I manage a referential as the same time and I test a peek() on the ref... yurk! pretty uggly!

Cheers

1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: testing if a mapping table exists

Mapping tables are invisible to table functions and script statements. A workaround I've used for your case is to set a variable when loading the table and test it later.  If required, you can use a compound variable name that takes into account the table you are working on. Something like:

SUB MySub(table)

IF len(mappingloaded.$(table))=0 THEN

  MAP_$(table):

  Mapping LOAD 1,2 AutoGenerate 1;

  SET mappingloaded.$(table)=true;

ENDIF

ENDSUB

CALL MySub('Customer')

CALL MySub('X')

CALL MySub('Customer')

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

View solution in original post

6 Replies
MVP & Luminary
MVP & Luminary

Re: testing if a mapping table exists

If I really needed to validate that the data was loaded into the mapping table, I'd first load the same data into a regular non-mapping table, then test what's needed to be tested, and then load the Mapping table as a resident load from the conventional table. It's an extra step, but I think it's the only way. AFAIK, you can't refer to the Mapping table in the script otherwise...

cheers,

Oleg Troyansky

Learn advanced Qlik techniques in my book QlikView Your Business.

shawn-qv
Contributor

Re: testing if a mapping table exists

During development, it's always a good idea to validate the data that you'll be loading later as a mapping table.

Are you using a mapping table for a different purpose perhaps?

S.

Not applicable

Re: testing if a mapping table exists

I develop with subs each sub is creating 1 table (fac or dim).

I need this massive mapping table in many subs.

During my development I'm reloading only the table/s I'm working on...not all the data model.

the test just say :if the mapping tables was not loaded before than load it, else use the one you already got in memory.

Just to make my like easier in dev...

MVP & Luminary
MVP & Luminary

Re: testing if a mapping table exists

Mapping tables are invisible to table functions and script statements. A workaround I've used for your case is to set a variable when loading the table and test it later.  If required, you can use a compound variable name that takes into account the table you are working on. Something like:

SUB MySub(table)

IF len(mappingloaded.$(table))=0 THEN

  MAP_$(table):

  Mapping LOAD 1,2 AutoGenerate 1;

  SET mappingloaded.$(table)=true;

ENDIF

ENDSUB

CALL MySub('Customer')

CALL MySub('X')

CALL MySub('Customer')

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

View solution in original post

Not applicable

Re: testing if a mapping table exists

Cool! we got a similar alternative... I was just hopping one of the function available can do that for me

Not applicable

Re: testing if a mapping table exists

Thanks a lot Rob!