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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
ift_isabelle
Partner - Creator III
Partner - Creator III

100% Stacked bar with aggregate

Hi,

I have customer data about their spend TV, Radio and Internet on a specific date, like in this table

CustomerMediumtypeDateSpend
ATV1/1/2016€ 100
ATV2/1/2016€ 600
ARadio1/1/2016€ 250
AInternet3/1/2016€ 20
BTV1/1/2016€ 80
BRadio1/1/2016€ 65

I want to make a 100% stacked bar chart per customer split on the mediumtypes. Like this:


Example.PNG

I tried to make an aggregation, but none of these work, it's not adding up to 100%:

sum({<year=2016,"Media Type"=>}Spend)/ aggr(sum({<year=2016,"Media Type"=>}Spend),Customer)

aggr(sum({<year=2016>}Spend), [Media Type], Customer)/ aggr(sum({<year=2016>}Spend), Customer)

sum({<year=2016>}Spend)/ sum(aggr(sum({<year=2016>}Spend),  Customer))

sum({<year=2016>}Spend)/ sum(aggr(sum( {<year=2016>}Spend), Customer))

sum({<year=2016>}Spend)/ sum( { total <year=2016>}Spend))


What am I doing wrong? Can you help me?

Thanks!

Kind regards,

Isabelle

1 Solution

Accepted Solutions
jagan
Partner - Champion III
Partner - Champion III

Hi,

Try

=sum({<year={'2016'}>}Spend)/ sum( { <year={'2016'}>} TOTAL <Customer> Spend)


Hope this helps you.


Regards,

Jagan.

View solution in original post

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try sum(Spend)/sum(TOTAL <Mediumtype> Spend)


talk is cheap, supply exceeds demand
ift_isabelle
Partner - Creator III
Partner - Creator III
Author

I tried sum(Spend)/sum(TOTAL <Customer> Spend) and that worked perfect!


Thanks!

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try

=sum({<year={'2016'}>}Spend)/ sum( { <year={'2016'}>} TOTAL <Customer> Spend)


Hope this helps you.


Regards,

Jagan.