Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

Try using

count(values). / count(total <category> values) and format your number as percent

View solution in original post

14 Replies
Clever_Anjos
Employee
Employee

Would you mind putting your expression?

Let´s play with some SUM(total <category> values)

Clever_Anjos
Employee
Employee

Please find attached an example

Not applicable
Author

I have a: count(values).

I just tried the SUM(total <category> values) and also count(total <category> values) but none of them is working..

And I can't open your attached example because I'm using a personal edition.

Clever_Anjos
Employee
Employee

Try using

count(values). / count(total <category> values) and format your number as percent

Not applicable
Author

It almost work. But everything is reaching 12.5% like (CO2: 8.5% and 4.5% / Gas: 11% and 1.5% etc...)

How to make it reach 100%??

But thank you for the answer!

Anonymous
Not applicable
Author

try  it.

Sum(fieldValue)/Sum(Total <Category> fielValue)

or

Sum(fieldValue)/Sum(Total fielValue)

and  Properties--Tag Number  Select

1.PNG

Regards!

Not applicable
Author

Still at the same point.

See what I get. I'm getting close but still not solved.

now.PNG

Not applicable
Author

I have 8 categories and that's why everything is over 12.5% and not 100%. I still have my "loop" problem. I need somewhere to put this foreach loop isnt it?

Anonymous
Not applicable
Author

you can  share  your  app please