Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Live chat with experts, bring your API Integration questions. June 15th, 10 AM ET. REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Error in expression values(minus sign for 0 value)


hello

I have derived one metrics in report.

Sales growth=(current sales-prev sales)/(prev sales)

In report current and prev values are same. So ideally it should display 0.0%

But it is displaying -0.0%.

There should not be any sign for 0 value.

Please find the attached image.

Thanks in Advance !!!

9 Replies
MK_QSL
MVP
MVP

if you make these numbers to two decimal, there could be difference.

please check and let us know

vikasmahajan
Champion
Champion

Go to Numbers -> Decimal -> 2 digit  then it will show some fractional value it is not zero in your case.

Vikas

Not applicable
Author

I have checked upto 5 decimals,but values are exact same.

MK_QSL
MVP
MVP

You can use below expression...

If(current sales = prev sales , 0, ((current sales-prev sales)/(prev sales)))

Not applicable
Author

Instead of percentage in the Numbers tab, tey showing it decimals or number format.

or you can try below:

(num(current sales)-num(prev sales))/(num(prev sales))

Not applicable
Author

I can't hardcode the values. Is there any other option for the same.

Or is anyone have idea that why the 0 is getting minus(-) sign.

Not applicable
Author

I have tried by the same way.

I have changed the decimal format to number. But it is displaying -0.

MK_QSL
MVP
MVP

have you used...

If(current sales = prev sales , 0, ((current sales-prev sales)/(prev sales)))

jonathandienst

Hi

This is a rounding error from the floating point arithmetic. Use Round() to eliminate:

     =Round((current sales-prev sales)/(prev sales), 0.1)

HTH

Jonathan

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