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: 
Not applicable

Stocked 100% with multiple expressions

Hi,

I have a chart with 1 dimension - Country

And 4 expressions that represent count of particular application types

sum(if([Application TypeCode]='G',1,0))

sum(if([Application TypeCode]='L',1,0))

sum(if([Application TypeCode]='M',1,0))

sum(if([Application TypeCode]='O',1,0))

My chart looks like this

error loading image

I need to create a Stocked Bar chart where each bar will be 100%. I have read post regarding stocked charts but can not figure how would I deal with 4 expressions.

Any help will be greatly appretiated

Yury

1 Solution

Accepted Solutions
Not applicable
Author

You should be able to divide each expression by the total value for that dimension. If each expression is divided by the total, they combined should equal 100% of that total.

sum(if([Application TypeCode]='G',1,0))/sum(1)


Also, try Set Analysis:

sum({<[Application TypeCode]={'G'}>} 1)/
sum({<[Application TypeCode]={'G','L','M','O'}>} 1)


That second one should be faster and more accurate if values other than G, L, M or O exist in the dataset.

View solution in original post

3 Replies
Not applicable
Author

You should be able to divide each expression by the total value for that dimension. If each expression is divided by the total, they combined should equal 100% of that total.

sum(if([Application TypeCode]='G',1,0))/sum(1)


Also, try Set Analysis:

sum({<[Application TypeCode]={'G'}>} 1)/
sum({<[Application TypeCode]={'G','L','M','O'}>} 1)


That second one should be faster and more accurate if values other than G, L, M or O exist in the dataset.

Not applicable
Author

Not sure, where do I enter this new last expression, instaed of each of mine?

Not applicable
Author

No, that last expression would replace your first one. Then use that as the basis for your second one, but replace the G. Basically, make each of your expressions like that one.

sum({<[Application TypeCode]={'G'}>} 1)/
sum({<[Application TypeCode]={'G','L','M','O'}>} 1)
sum({<[Application TypeCode]={'L'}>} 1)/
sum({<[Application TypeCode]={'G','L','M','O'}>} 1)
sum({<[Application TypeCode]={'M'}>} 1)/
sum({<[Application TypeCode]={'G','L','M','O'}>} 1)
sum({<[Application TypeCode]={'O'}>} 1)/
sum({<[Application TypeCode]={'G','L','M','O'}>} 1)


Use each of those as an expression and you should get what you are looking for.