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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Optimize Expression without IF

Dear all,


This is my expression : Num( Sum(Sale) / Sum( Quantity)*100,'#.#')&'%'

I''d like to reduce '%' when the result of sum equal zero and without IF expression. I need your help,pleaseee!!

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Do you mean hide the % when the value is zero?

In what context do you want to display this number?

You could do this:

Num(Sum(Sale) / Sum( Quantity)*100, '0.0%;-0.0%';0)

This will use the appropriate format for positive, negative and zero respectively

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

6 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Do you mean hide the % when the value is zero?

In what context do you want to display this number?

You could do this:

Num(Sum(Sale) / Sum( Quantity)*100, '0.0%;-0.0%';0)

This will use the appropriate format for positive, negative and zero respectively

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable
Author

Thank you very very much jontydkpi

Anonymous
Not applicable
Author

Hi jontydkpi‌,

I am so sorry about that. Last day, I just check the zero value  and I miss to check correct format.

I provide the following photo:

Capture.JPG

I wanna format % as the left photo. Can you give me advice for this problem?

Regards!

Kirk

jonathandienst
Partner - Champion III
Partner - Champion III

Well the %format effectively multiplies by 100, so 0.5 displays as 50%. Just remove the *100 from the expression.

=Num(Sum(Sale) / Sum( Quantity), '0.0%;-0.0%';0)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Digvijay_Singh

Do you have Comma ',' before last zero? I guess it should be semicolon. I think 0.0% and -0.0% and the 0 are separated by semicolon and enclosed with apostrophe, try this - '0.0%;-0.0%;0'. jontydkpi might have typo in last response.

Anonymous
Not applicable
Author

yup, thank you and.. the number after dot will be rounded.

The data after remove *100 :

Capture.JPG

I wanna get the number after dot. I dont wanna be rounded number. Like left value. Do you mind if you .... fix it again ? ?