# Thread: Calculated field in a browse table

1. ## Calculated field in a browse table

Hi
I have a browse table which list rows of bookings that have been made on the current day, it has one calculated field which gives the total of the bookings.

The calculated field is: total = total(Number_Of_Dels)

In this calculated field I need to exclude records that have the words 'Transferred' or 'Inhouse' in another field called Resp_type from the total. I have tried with if statements and marking records. I can get the correct 'total' by marking the records but then the marked records don't appear in the browse table.

I would appreciate any help, pointers on how to achieve the total without losing the marked records in the browse table.

Judith

2. ## Re: Calculated field in a browse table

Total() doesn't accept a filter. To get the result you want I suggest you look at changing to tablesum().

Something like tablesum("your_table_name","Resp_type != 'Transferred' .and. Resp_type != 'Inhouse'","Number_Of_Dels")
or tablesum("your_table_name",".not. (Resp_type = 'Transferred' .or. Resp_type = 'Inhouse')","Number_Of_Dels")

3. ## Re: Calculated field in a browse table

Stan you come up with the most interesting stuff - eg. I did not know that .not. could be used with field types other than logical. I am thinking of adding a new subscription category for 'Stan Fixes' ...

4. ## Re: Calculated field in a browse table

Well, actually the field type doesn't matter. My expression just reversed the logical result of the character expression (Resp_type = 'Transferred' .or. Resp_type = 'Inhouse')".

You can

? .not. (1=2)
= .T.

and you can

? invert(1=2)
= .T.

And using .and. or .or. can be fun.

? 2 .and. 1
= 0
? 2 .or. 1
= 3

And to muddy the waters further.

Code:
```? convert_type(1,"L")
= .T.
? convert_type(0,"L")
= .F.
? convert_type("1","L")
= .T.
? convert_type("0","L")
= .F.
? convert_type(.T.,"N")
= 1
? convert_type(.F.,"N")
= 0
? convert_type("False","L")
= .F.
? convert_type("True","L")
= .T.
? convert_type(.T.,"C")
= "True"
? convert_type(.F.,"C")
= "False"```

5. ## Re: Calculated field in a browse table

Thank you Stan - where would we be without you. I have included the expression in the browse table and it works a treat.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•