Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

nsnybs21qv
New Contributor II

Create Pivot Table in Load Script

Hi QV Expert:

I'm trying to create a pivot table in the load script because I need to add other calculation in the front end. My source data is in chart 1. The processed table should look like chart 2, with columns…

  • Preferred (N)/ Preferred (Y): the count of sellers that are labeled N/Y in the Preferred column in chart 1.
  • % of Preferred: Preferred (Y)/(Preferred (Y)+Preferred (N))
  • Has Preferred?: Y if Preferred (Y)> 0

Can someone help with the script? I was using  "if (Preferred= 'Y', Count ([Seller]),0) as 'Preferred (Y)'" for Preferred (Y),   but it didn't seem to work…

Thanks!

chart 1  

ItemSellerPreferred Seller
AppleFarm AY
AppleFarm CN
OrangeFarm CN
OrangeFarm AY
OrangeFarm BN
PearFarm BN
PearFarm AY
Watermelon Farm BN
Watermelon Farm DN

Chart 2   

   

ItemPreferred (N)Preferred (Y)% of PreferredHas preferred?
Apple1150%Y
Orange2133%Y
Pear1150%Y
Watermelon 200%N
Tags (2)
1 Solution

Accepted Solutions
sinanozdemir
Valued Contributor III

Re: Create Pivot Table in Load Script

Hi,

Here is my approach:

Capture.PNG

Here is the data model:

Capture.PNG

Capture.PNG

I am also attaching the qvw.

Hope this helps.

1 Reply
sinanozdemir
Valued Contributor III

Re: Create Pivot Table in Load Script

Hi,

Here is my approach:

Capture.PNG

Here is the data model:

Capture.PNG

Capture.PNG

I am also attaching the qvw.

Hope this helps.

Community Browser