Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor

getting % of total

i have  a stacked chart and need to calculate the % of total.. so that overall it will be 100%. There are two dimensions date and cust type

X axis has date.

the numerator works fine and gives me the number. But the complete formula is not working. 

Sum(if(period_id='CY' , customer_cnt))
/ SUM(TOTAL IF(period_id='CY', aggr(sum (customer_cnt),[Local Date])))

1 Solution

Accepted Solutions
Creator II
Creator II

Hi, 

Try this one

Sum(if(period_id='CY' , customer_cnt))
/Aggr(nodistinct Sum(if(period_id='CY' , customer_cnt)),[Local Date])

 

ZZ

 

View solution in original post

4 Replies
Highlighted
Creator II
Creator II

Have you tried something like this?
Sum(if(period_id='CY' , customer_cnt))
/ sum(TOTAL Aggr(Sum(if(period_id='CY' , customer_cnt)),[Local Date]))

ZZ
Highlighted
Contributor
Contributor

Hi ZZ,

thanks for looking into it. I tried your logic

the denominator actually gives the overall total of customer_cnt instead of the total for that date on x axis. Due to which %'es are not right for the cust_type split. Ideally it should be total of 100% based on the cust_type split

Attaching the screenshot. 

Creator II
Creator II

Hi, 

Try this one

Sum(if(period_id='CY' , customer_cnt))
/Aggr(nodistinct Sum(if(period_id='CY' , customer_cnt)),[Local Date])

 

ZZ

 

View solution in original post

Highlighted
Contributor
Contributor

thank you. This formula worked.