May 7, 200619 yr Hello, Is there a way to make a conditional count using a single script ? For example: Count ((Invoices::Balance) > 0 ) The above line is not accepted. The intension is to count all records whose balance is non zero. Of course this could be done by setting a seperate calculation field as a flag and then counting the flags .... but can it be done more elegantly by script without introdusing new fields?
May 7, 200619 yr I'm slightly puzzled here, the payment is done in the table for invoices? Are you accepting partial payments for one invoice? Well Show All Records Go to Record/Request/Page [ Last ] Loop If [ invoices::Total > invoices::Payment ] Omit Record Else Go to Record/Request/Page [ Previous; Exit after last ] End If End Loop Show Omitted Only Show Custom Dialog [ Title: "Invoices whose balance is non zero."; Message: Get ( FoundCount ); Buttons: “OK” ] Show All Records --sd
May 7, 200619 yr Author SD, Thank you for this hint. I will give it a try using your script suggestion. About the invoices (sorry to confuse you) it was chosen by way of example. In reality it is the "projects" table and tracks all info about a project including total value and payments received to date. So we need to know (just as a statistic) how many projects still have outstanding balances. Again, many thanks for your help Best Regards, Thomas
May 7, 200619 yr For a "live", self-updating calculation, you need to add that extra field. If you prefer a static snapshot, you can simply do a find for >0 in the Balance field.
May 8, 200619 yr Author For a "live", self-updating calculation, you need to add that extra field. If you prefer a static snapshot, you can simply do a find for >0 in the Balance field. Thank You. Yes, "live self-updating" calculations are always a high priority. This particular count will be a numeral (live statistic) on top of a portal. Regards, Thomas
May 8, 200619 yr This: For a "live", self-updating calculation, you need to add that extra field. ...kind of defeats the object with this: but can it be done more elegantly by script without introdusing new fields? ...but whether it's more or less elegant, won't I be the judge! --sd
May 8, 200619 yr ...Alternatively, you could add an extra field in your related table: Calc field, with result: If(Balance = 0 ; "" ; "A") And then count this from your other side. The reason this will work is because count only counts records where that field is not empty. ~Genx
May 8, 200619 yr Oh right... no new fields.. oops.. Still, i dont see whats so bad about adding an extra field...
Create an account or sign in to comment