Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
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
Highlighted
Creator II
Creator II

Re: getting % of total

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

Re: getting % of total

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

Re: getting % of total

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. 

Highlighted
Creator II
Creator II

Re: getting % of total

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

Re: getting % of total

thank you. This formula worked.