# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Customers, Partners & Luminaries only: You're invited to a Data Analytics Roadmap session. Read More
cancel
Showing results for
Did you mean: 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

Hi,

Try this one

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

ZZ

4 Replies
Highlighted 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

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

Hi,

Try this one

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

ZZ

Highlighted Contributor

thank you. This formula worked.  