Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
1 Solution

Accepted Solutions
sinanozdemir
Specialist III
Specialist III

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.

View solution in original post

1 Reply
sinanozdemir
Specialist III
Specialist III

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.