Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to put a loop in my expression?

Hello everybody,

I need your help for a bar chart where i need to see everything over 100%.

I have tried to check the box "relative" and it's close to work but the problem is:

If I select only one of my categories then this category is well over 100% (f.e.g. 56% True and 44% False)

But if I want to see all my categories then the total is over 100% but each one of the category is over 25%, 5% etc...

That's why I wanted to put a loop "foreach" like "foreach categories, do the expression" but it seems like I can't put a loop in an expression.

I'm not sure to be clear in my request. So I link to pictures: What I have and what I needHaveThis.PNGneedThis.PNG

14 Replies
Not applicable
Author

Sorry but I can't share it.

Not applicable
Author

scramble your data if this is sensitive or try to create an example application to share, it is difficult to resolve without seeing what your underlying data model looks like

Joe

vincent_ardiet
Specialist
Specialist

Hi Tristan,

It's strange because it should work.

I have build an example and it produces the expected result.

In the script I have a table like this:

 

LOAD * INLINE

[
Category, Status, Value
co2, 1, 45
coal, 1, 6
crude, 1, 89
formula, 1, 124
fuel, 1, 34
co2, 0, 8
coal, 0, 15
crude, 0, 10
formula, 0, 24
fuel, 0, 50
]
;

Then I have a chart with Category and Status in dimension and the following expression  =sum(Value)/sum( total <Category> Value)

And I have choosed in the number format Integer and Show in Percent.

Not applicable
Author

True, your example is working, I tried it. Then I don't get why it's not working with my datas..

So thanks for helping, I ll try by my own now to solve it..

Thank all of you for your help!

Not applicable
Author

Well it's working finally !!!! I have to not to check the "relative" box! Thank You!