Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

danieloberbilli
Valued Contributor II

Data iteration problem

Dear all,

Please find attached my .qvw file with the following problem:

I need to transform my source data fields in a certain way and I am pretty sure that I need an iteration function for that.

Please be aware, that this is only a very simple and abstract way of displaying my data - the real case includes several thousand of categories and Value-Fields.

Here is the problem:

A,B,C are 3 different categories

The Value-fields contain null,0 or 1

Problem: the Value fields are not directly linked to the right category

They have a placeholders X and Y that could be A,B or C

The two fields X and Y provide the information if the value of Value_X and Value_Y belong either to A,B or C

As a result I need a Value-Field for each category:

Capture.PNG.png

Thanks a lot for your time and help.

Daniel

1 Solution

Accepted Solutions
Not applicable

Re: Re: Data iteration problem

Hi Daniel, Please find the attached qvw and let me know in case of any concerns.

10 Replies

Re: Data iteration problem

Hi Daniel,

generally your example worked with quite simply if-loops. If there are thousands (or too many for typing manually) of categories I suggest to load distinct all categories and create with variables a load-statement within in a loop in a stream-structure like:

table:

ID     Categorie     Value

instead to create a table with thousands of columns.

for i = 0 to noofrows('DistinctCategories') - 1

     vCategorie = peek('Categorie', $(i), 'DistinctCategories')

     Load-Statement ...

next

- Marcus

danieloberbilli
Valued Contributor II

Re: Data iteration problem

Thank you so much, Marcus!

In this loop structure where you mention: 'Load-Statement' ...how would this load-statement look like? Does this mean I have to generate a single temporary table for each category and concatenate all of them in the end?

It would be great if you could give me a short example of this load statement.

Thanks again!

Daniel

Re: Data iteration problem

It looks basically like a GENERIC LOAD problem. See attached. It won't matter how many categories you have. However, if you have many more value columns, there may be a trick of folding the table down using CROSSTABLE followed by GENERIC. I'd have to think about it. But see if the attached gives you an idea.

More on GENERIC LOAD in the Ref Guide and here.

http://qlikviewnotes.blogspot.com/2010/05/use-cases-for-generic-load.html

-Rob

http://masterssummit.com

danieloberbilli
Valued Contributor II

Re: Data iteration problem

Thank you, Rob. I think using generic loads is a smart way but as I am not familiar in creating loops/iterations in QlikView, I don't figure out how to transform your example to my case where I have several fields providing the category and several fields with the value-information.

Daniel 

Not applicable

Re: Re: Data iteration problem

Hi Daniel, Please find the attached qvw and let me know in case of any concerns.

Re: Re: Data iteration problem

Sorry Daniel, I forgot to attach the example! Here it is and it appears that Dathu has attached a similar example.

-Rob

http://masterssummit.com

danieloberbilli
Valued Contributor II

Re: Data iteration problem

Thank you, Rob. Unfortunately your qvw attachment didnt include any script   but as you said before...Dathu gave a similar example which works fine for me.

All the best

Daniel

danieloberbilli
Valued Contributor II

Re: Data iteration problem

Excellent, Dathu! With this example I learned a lot of using iterations...thank you so much!

All the best

Daniel 

Not applicable

Re: Data iteration problem

Your welcome.

Community Browser