Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Not applicable

Show trend when second value is zero

Hello,

This is a newbish questions,

But if i wanna show a trend based on two values i divied them,

So eg i have:

sum(amount) / sum(amount2)

Lets say

Sum(amount) = 1 and sum(amount2) = 0

Then i want a trend which says its 100% , but as everybody knows, you cannot divied by zero.

What can i do?

Tags (1)
1 Solution

Accepted Solutions

Re: Show trend when second value is zero

Hi,

       its wrong cause

     Sum({<CW={1}>} TotalRows) / sum({<PW={1}>} TotalRows) will never be zero when its 1/0.

     so your expression should be

     Sum({<CW={1}>} TotalRows) / if(sum({<PW={1}>} TotalRows)=0,1,sum({<PW={1}>} TotalRows))

Regards,

Kaushik Solanki

5 Replies

Re: Show trend when second value is zero

Hi,

     You can use the if statement to check whether the sum(Amount2) is 0 or not, if its zero then replace it by 1.

     in that case 1/1 will be 100%

Regards,

Kaushik Solanki

Not applicable

Re: Show trend when second value is zero

I already tried that, but i cannot seem to get it to work then?

I tried

=if(Sum({<CW={1}>} TotalRows) / sum({<PW={1}>} TotalRows) = 0,1,Sum({<CW={1}>} TotalRows) / sum({<PW={1}>} TotalRows))

However i might did something wrong?

v_iyyappan
Valued Contributor

Re: Show trend when second value is zero

Use like this

=If(Sum(amount2) > 0, Sum(amount) / Sum(amount2), Sum(amount))

Regards,

Re: Show trend when second value is zero

Hi,

       its wrong cause

     Sum({<CW={1}>} TotalRows) / sum({<PW={1}>} TotalRows) will never be zero when its 1/0.

     so your expression should be

     Sum({<CW={1}>} TotalRows) / if(sum({<PW={1}>} TotalRows)=0,1,sum({<PW={1}>} TotalRows))

Regards,

Kaushik Solanki

Not applicable

Re: Show trend when second value is zero

Ahhhh! Ofc!

Stupid me! Thanks alot!

Community Browser