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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Division by NULL

Am trying to work out a formula which calculates the increase/decrease in sales (premium) for a selected year compared to the previous year.

Formula below works fine except in one circumstance where the sales (premium) for the previous year (year-1) is empty. 

if((sum({$<Year = {$(=Only(Year))}>} Premium) -
(
sum({$<Year = {$(=Only(Year)-1)}>} Premium)))/
(
sum({$<Year = {$(=Only(Year)-1)}>} Premium))>=0,1,0)))

Any suggestions please?

thanks!

steve

4 Replies
Clever_Anjos
Employee
Employee

alt(

if((sum({$<Year = {$(=Only(Year))}>} Premium) -
(
sum({$<Year = {$(=Only(Year)-1)}>} Premium)))/
(
sum({$<Year = {$(=Only(Year)-1)}>} Premium))>=0,1,0))),

0 // or another default value

)

Not applicable
Author

formula doesn't accept anything after the >=0,1))

Clever_Anjos
Employee
Employee

Sorry, too much ")"

=alt(

if((sum({$<Year = {$(=Only(Year))}>} Premium) -

(sum({$<Year = {$(=Only(Year)-1)}>} Premium)))/

(sum({$<Year = {$(=Only(Year)-1)}>} Premium))>=0,1,0),

0 // or another default value

)

angelaecheverri
Creator
Creator

i guess in order to have a better performance...

use in chart propieties, presentation tab unselect null symbol and missing symbols at the left end of the windown

and use a simple expresion

(

sum({$<Year = {$(=Only(Year))}>} Premium) -
sum({$<Year = {$(=Only(Year)-1)}>} Premium)

) /
sum({$<Year = {$(=Only(Year)-1)}>} Premium)

Captura.PNG.png