1. Wayne Wan
  2. PowerBuilder
  3. Tuesday, 28 April 2020 04:16 AM UTC

A treeview datawindow, i add a compute field in the group band which named "subtotal". Its value depends on a complex function. 

My question is , how to add these compute field together?   

Something like:

GroupBand  a   subtotal=10

    DetailBand a1

    DetailBand a2

GroupBand  b  subtotal = 20

   DetailBand b1

=====================

i need get the result of  10 + 20 = 30.  But a1 + a2 + b1 <> 30.

 

 

René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 28 April 2020 05:47 AM UTC
  2. PowerBuilder
  3. # 1

Hi Wayne,

It's not so easy to answer without knowing more about the calculation in your subtotal field.

Usually you have an aggregate function like sum that you use for the group, e.g. sum(a for group 1) So to get the total sum if you use the same expression and replace "for group 1" by "for all", e.g. sum(a for all).

But I guess it is not so easy for you?

You could try this:

  • Create a computed field (I call it "subtotal_helper") with following expression:

    if(getrow () = first( getrow() for group 1 ), subtotal, 0)

  • The expression for you summary field:

    sum (subtotal_helper for all)

(You could also use last aggregate function instead of first.)

HTH,

René

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.