Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Make your voice heard! Participate in the 2020 Wisdom of Crowds® Survey. BEGIN SURVEY
Highlighted
kirkleehuang
New Contributor III

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
Highlighted
MVP
MVP

Re: Optimize Expression without IF

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
Highlighted
MVP
MVP

Re: Optimize Expression without IF

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

Highlighted
kirkleehuang
New Contributor III

Re: Optimize Expression without IF

Thank you very very much jontydkpi

Highlighted
kirkleehuang
New Contributor III

Re: Optimize Expression without IF

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

Highlighted
MVP
MVP

Re: Optimize Expression without IF

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
Highlighted
Digvijay_Singh
Honored Contributor III

Re: Optimize Expression without IF

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.

Highlighted
kirkleehuang
New Contributor III

Re: Optimize Expression without IF

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 ? ?