Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
upaliwije
Creator II
Creator II

Percentage

=if(I_DAY >= 0 and I_DAY <=15, dual('1-15 Days',1),

if(I_DAY >= 16 and I_DAY <= 25,dual('16-25 Days',2),

if(I_DAY > 25, dual('> 25 Days',3))))

I have above calculated dimension in my pivot table and the resulting out put is as follows

Month1-15 Days16-25 Days> 25 DaysTotal
Jan25,00040,00050,000115,000
Feb75,000150,000250,000475,000
Mar60,000250,00035,000345,000
Total160,000440,000335,000935,000

But I want to insert the percentages to this pivot table to look it like as follows

Month1-15 Days%16-25 Days%> 25 Days%Total
Jan25,0002240,0003550,00043115,000
Feb75,00016150,00032250,00053475,000
Mar60,00017250,0007235,00010345,000
Total160,00017440,00047335,00036935,000

Pls help me to write expression to show the % values

Labels (1)
6 Replies
hic
Former Employee
Former Employee

If you perform you calculation in the script:

     if(I_DAY >= 0 and I_DAY <=15, dual('1-15 Days',1),

     if(I_DAY >= 16 and I_DAY <= 25,dual('16-25 Days',2),

     if(I_DAY > 25, dual('> 25 Days',3)))) as DelayClass

then you can calculate the percentages as

     Sum(Amount) / Sum(total <Month> Amount)

HIC

hic
Former Employee
Former Employee

In fact, you can do the same also with a calculated dimension... Just create a second expression using

         Sum(Amount) / Sum(total <Month> Amount)

HIC

sujeetsingh
Master III
Master III

You can use another Expression as Labeled '%' and expression as Heneric suggested.

upaliwije
Creator II
Creator II
Author

Thanks Henric

But when I add your code to script I get a following message when relaoding

Script Line error

if(I_DAY >= 0 and I_DAY <=15, dual('1-15 Days',1),


Pls help to rectify

hic
Former Employee
Former Employee

Well, you need to give more information than just "Script Line error"... I don't know what your script looks like.

HIC

CELAMBARASAN
Partner - Champion
Partner - Champion

You could try Sum(Amount) / Sum(total <Month> Amount) to get percentage.