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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
neetishrai
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
zzyjordan
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
zzyjordan
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
neetishrai
Contributor
Contributor
Author

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. 

zzyjordan
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

 

neetishrai
Contributor
Contributor
Author

thank you. This formula worked.