Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Chanty4u
MVP
MVP

Expresion error

Hi all,

Sunny T

how to use Sum with First sortedvalue

I have to get sum of balance  .. but the values is showing wrong with below expression.

=

sum(if (

  isnull(FirstSortedValue([Balance], ssDate))

  ,

  0

  ,

  FirstSortedValue([Balance], ssDate)

  )

)

Can anyone advice with correct syntax

Thanks

Chanty

19 Replies
Gysbert_Wassenaar

=rangesum(FirstSortedValue([Balance], ssDate),0)


talk is cheap, supply exceeds demand
Chanty4u
MVP
MVP
Author

thanks gwassenaar. but it is also not working  chk below image

as closing balance should not be in Negative  . and opening balance is showing "0" only

Gysbert_Wassenaar

How To Ask Questions The Smart Way


talk is cheap, supply exceeds demand
Anil_Babu_Samineni

chanty,


I didn't find your calculation value. Can you post full expression. Sum(sales) similar that where is your SUM calculation field.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Chanty4u
MVP
MVP
Author

Hi anil,

this is for Closing balance : working fine

if

  (

  isnull(FirstSortedValue([Balance], TBDate))

  ,

  sum(0) + Sum (Debit) - Sum (Credit)

  ,

  FirstSortedValue([Balance], ssDate) + Sum (Debit) - Sum (Credit)

  )

this is for openg bal :Not working

=

sum(if (

  isnull(FirstSortedValue([Balance], ssDate))

  ,

  0

  ,

  FirstSortedValue([Balance], ssDate)

  )

)

sunny_talwar

Not sure, but did you try Gysbert's solution with a DISTINCT?

=RangeSum(FirstSortedValue(DISTINCT [Balance], ssDate),0)

Chanty4u
MVP
MVP
Author

it is givng error  sunny  not allowing to use Distinct.  chk below image for your ref

sunny_talwar

Expression Editor doesn't understand the syntax, try clicking ok and see if the result comes out as desired. This was an issue in the older version of QlikView.

Chanty4u
MVP
MVP
Author

yes sunny even though result is wrong it self.

it is not caluclating the sum  and the closing balance is showing  negative.