1. Hesham Hasan
  2. PowerBuilder
  3. Monday, 5 February 2018 05:02 AM UTC

Hello,

I have a report datawindow with computed columns and a button to sort the datawindow based on a computed column.

The code for the button looks something like this:

dw_rpt.SetSort('')
dw_rpt.SetSort("compute_6 desc")
dw_rpt.Sort()

For reference, this is the code of compute_6 :

sum(if(( daysafter(aptrans_voucherdate, today()) + 1 >=31 and daysafter(aptrans_voucherdate, today()) + 1 <=60 ),compute_16 , 0)  for group 1)

 

When the button is clicked, the values of the computed column with look like this:

See that some values are not getting ordered correctly.

 

I tried integer(compute) and cast(compute as int) but the results are the same.

Is there way to solve this?

Thanks.

René Ullrich Accepted Answer Pending Moderation
  1. Monday, 5 February 2018 12:02 PM UTC
  2. PowerBuilder
  3. # 1

I'm not sure but I guess it can't work as you want.

The computed field calculates a value for a group. A group are sequential rows with same values for one or more columns. So a group depends on the sort order of the datawindow. So if you change the sort order the group calculation also changes. But in your case the sort order depends on the group.

I'm not sure what you really want. If you want to order the groups you should use the group sort.

Comment
There are no comments made yet.
François Rossignol Accepted Answer Pending Moderation
  1. Monday, 5 February 2018 07:53 AM UTC
  2. PowerBuilder
  3. # 2

Hi,

I had trouble with sorting computed in PB 12.5, what I did at the time to fix that is using the "formula" directly in the setSort instead of the name of the computed field.

Not ideal but might work for you.

 

Regards

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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.