1. John Vanleeuwe
  2. PowerBuilder
  3. Thursday, 1 August 2019 14:37 PM UTC

Hi all,

 

i have a datawindow which can contain thousands of records , each record has a status code.

 

Lets say status can be 0, 1, 2, 3 , 4

 

What is the fastest way of showing the user how many records with status 0 there are , status 1 and so on.

 

I have a grid datawindow which i want to keep like it is. So i can't use the group function , this will change the datawindow which i don't want.

 

I was trying the filter function also , but this flashes my screen a lot ( filter on status 0 , filter on status 1 , and so on to retrieve everything  again )

 

Just not sure what is the best way to achieve this.

 

 

TIA

John

Michael Hartnett Accepted Answer Pending Moderation
  1. Thursday, 1 August 2019 14:46 PM UTC
  2. PowerBuilder
  3. # 1

Hi John,

We have had to do similar before.

What we do is create a hidden computed field on the row for each of the statuses.  Simply set the value to 1 or 0.

i.e.

c_zero, c_one, c_two, etc...

if Status is 0 then set the value of c_zero = 1 else 0, something like this if(statuscode = 0,1,0).  Use the same logic for each of the computed fields and their corresponding statuscode.

Finally in the Summary or Footer of your Grid, simply sum the values in the computed field.  "Sum(c_zero) for all"

Hope that helps.

Michael

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 1 August 2019 15:30 PM UTC
  2. PowerBuilder
  3. # 2

I've done something similar on occasion to what Michael proposes, with a slight variation:

Add the hidden computed fields containing the "If" statement, one for each status value as Michael describes. Then instead of adding computed fields in the Summary or Footer bands to display the summed count of each status value (which changes the DataWindow), add a tooltip for the the status column that displays all of the summed counts, such as:

'Counts:~r~n' + 0: ' + string(sum(c_zero for all)) + '~r~n' + '1: ' + string(sum(c_one for all) + '~r~n' + .....

HTH

John

Comment
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Thursday, 1 August 2019 16:28 PM UTC
  2. PowerBuilder
  3. # 3

you don't have to add anything except the display in the summary band:

 

'total status 1 = ' + sum( if( status = 1, 1, 0) for all)   

'total status 2 = ' + sum( if( status = 2, 1, 0) for all) 

...

for your various counts

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.