Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
renuka_sasikumar
Creator III
Creator III

Negative No. is not getting considered in IF Condition.

HI,

I have two dimension Gross_BRK & TOT_Passout.


TOT_PassoutGROSS_BRK
-13.10
35.453.1
35.8353.75
54.19581.3

I have an expression where I have written,

if(SUM(TOT_PASSOUT)<0,

  SUM(Gross_BRK)

  ,

    (SUM(Gross_BRK)-SUM(TOT_PASSOUT))

)

Here Net_Amount should be 62.72 but I am getting 75.82.

The Negative numbers are not been considered in this expression.

Can anyone help me where the Negative No should be considered.

Thanks & Regards,

Renuka S

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Simpler, but equivalent to the above:

=Sum(GROSS_BRK - RangeMax(0, TOT_Passout))

If either value could be NULL:

=Sum(RangeSum(GROSS_BRK, -RangeMax(0, TOT_Passout)))

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

View solution in original post

8 Replies
Digvijay_Singh

Which chart you are using and what is the dimension you are using. Keep in mind 0-(-13.1) is +13.1. If you can share more info, will understand better.

renuka_sasikumar
Creator III
Creator III
Author

Hi Digvijay,

Thanks for your prompt reply.

I tried using Pivot as well as Straight Table, Dimension is only Date.

I have written condition that if my TOT_PASSOUT<0 then Considered SUM(GROSS_BRK).

But this is not working its not working...

Digvijay_Singh

If you change expression total to sum of rows it shows correctly.

sumofrows.PNG

Dim.PNG

renuka_sasikumar
Creator III
Creator III
Author

I tried this, but I want two show in Pivot Table, Sorry as I said only Date as Dimension but there is one more dimension as Source ID

Thanks & Regards,

Renuka S

Digvijay_Singh

This works perfectly for you -

Sum(if(TOT_Passout<0,GROSS_BRK,GROSS_BRK-TOT_Passout))

working.PNG

jonathandienst
Partner - Champion III
Partner - Champion III

Simpler, but equivalent to the above:

=Sum(GROSS_BRK - RangeMax(0, TOT_Passout))

If either value could be NULL:

=Sum(RangeSum(GROSS_BRK, -RangeMax(0, TOT_Passout)))

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
renuka_sasikumar
Creator III
Creator III
Author

Hi,

Actually My expression is this

IF(Value='Gross',SUM({$<Segment={'Equity'}>}Gross_BRK)/vLakhs,

IF(Value='Net',

if(SUM({$<Segment={'Equity'}>}TOT_PASSOUT)<0,

  SUM({$<Segment={'Equity'}>}Gross_BRK)/vLakhs

  ,

    (SUM({$<Segment={'Equity'}>}Gross_BRK)-SUM({$<Segment={'Equity'}>}TOT_PASSOUT))/vLakhs

)

))

Thanks & Regards,

Renuka S

renuka_sasikumar
Creator III
Creator III
Author

Hi,

Thank you Jonathan its working.

Thanks & Regards,

Renuka S