Question

I am populating a DataWindow with some data. Some of the column names are "Request No", "Status", etc.

"Status" column can contain values like "Pending", "Active","Expired".

Whenever the DataWindow is populated I want to count the number of records in PowerBuilder which are having status as "Active".

After getting the count of the records I will be populating the count in some static text.

Can anybody help me , how to achieve this, as I am new to PowerBuilder.

Thanks

Was it helpful?

Solution

This will get you your answer, but it introduces you to what we PowerBuilder developers know as "Tilde Hell".

ll_Count = Long (dw.Describe ("Evaluate('sum (if((status = ~~~"Active~~~"),1,0))',1)"))

The tilde-craziness has to do with what each level of string evaluation boils the expression down to for the next evaluation. (~~ boils down to ~, and ~" boils down to " which is useful if your string is enclosed in double quotes)

Evaluate(<expression>, <row>) inside a Describe() will return the value for <expression> on a given row. (Since <row> is irrelevant to a sum() operation which works across the full data set, all you need to do is make sure it's a valid row, i.e. in this example, that there is at least one row.)

Good luck,

Terry.

OTHER TIPS

One solution is to filter the DW data by using your criteria, then to get the rows count.

Something like:

dw_ctrl.SetFilter("status='Active'")
dw_ctrl.Filter()
ll_count = dw_ctrl.RowCount()
//...
//don't forget to reset filter after that
dw_ctrl.SetFilter("")
dw_ctrl.Filter()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top