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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Mario1011
Contributor
Contributor

help with divide by zero - needs to display 100%

I have the following expression in my table to handle divide by zero....

I have a variance % column which needs to display it as 100% and not 0%

=Alt((sum({$<Type={'Actuals'}>}Amount)/sum({$<Type={'Budget'}>}Amount)-1)*1, '0')

I've tried changing the '0' to '1'...... but this essentially breaks my table?

If statement perhaps???

2 Replies
DavidM
Partner - Creator II
Partner - Creator II

You can do it with if like this:

If (

(sum({$<Type={'Actuals'}>}Amount)/sum({$<Type={'Budget'}>}Amount)-1)*1)=0,

1,

(sum({$<Type={'Actuals'}>}Amount)/sum({$<Type={'Budget'}>}Amount)-1)*1)

Mario1011
Contributor
Contributor
Author

I ended up using this:

=if(sum({$<Type={'Budget'}>}Amount)= 0, (sum({$<Type={'Actuals'}>}Amount)/sum({$<Type={'Actuals'}>}Amount))*1, sum({$<Type={'Actuals'}>}Amount)/sum({$<Type={'Budget'}>}Amount)-1)*1