Calculate in Meta (Sum Up Currency Values)

Hi,

I use Devonthink also to track insurance claims with multiple insurance companies. they all refund a bit or nothing. in the end i´d like to know if i was reimbursed in full or not.

so i use custom meta data to keep track of reimbursements, if the claim is active or done …

and now i would love to have an option to actually calculate the end-sum of a file… so a meta data field that sums up other metadata fields … is that possible somehow? (or in a different way?)

thanks! cheers, arne

Offhand I am not aware of a function which sums up metadata fields. It would be simple enough to script, though. A script run either on demand or at regular intervals could tot up any records which had entries in appropriate metadata fields.

My solution is an applescript

My use case is receipts and bank transactions stored as notes in DT
Amount is appended to the title (or within the note contents)
I track two amounts; paid and insurance refund (id’d by tags)

A script is run monthly and extracts the data; it could do the summing
In my case, the data is exported to a spreadsheet for budget/expense reporting

I’ve noticed that when you have:

  1. metadata info tab viewable (ctrl-2) and then
  2. select records with filled currency custom metadata fields.

if you look at the metadata tab it will add up the values of the selected records. I don’t know how to get at that automatic summing but it’s handy for getting a quick total when you want to see how much scratch you’ve spent on fancy lattes or what have you.

5 Likes

if you look at the metadata tab it will add up the values of the selected records.

I have never noticed this effect! :open_mouth: :smiley:

5 Likes

Glad I could momentarily reverse the flow of information about DevonThink with this tiny granule of knowledge.
Now it’s back to being the student for me.

3 Likes

Hi DTLow, thanks for the info. Would you mind sharing that script to show how these references and syntax would look like? Would love to try and adapt it for my use case. Thanks.

As I indicated, I was tracking two amounts, paid and insurance refund (id’d by tags)
Number crunching can be done in an applescript but I exported to a spreadsheet for that

The first challenge is to store the amounts in Devonthink
Example 1; a receipt for an insurance refund payment
Note Name: 2021-05-01 Receipt [Insurance refund] … $150
Tag: !Budget-HealthInsurance
Example 2: a receipt for prescription drugs, insurance deducted at purchase
Note Name: 2021-05-01 Receipt [Prescriptions] … $-40
Tag: !Budget-HealthPrescriptions
Note Contents: [Tag_!Budget-HealthPrescriptions $-75] [Tag_!Budget-HealthInsurance $35]

The script code to parse the title is
set theOffset to (offset of “$” in theTitle) + 1
set theAmount to texts theOffset thru -1 of theTitle

The script code to parse the note contents is

set AppleScript's text item delimiters to "[Tag_!Budget-"
set budgetItems to every text item of theText
set itemCount to number of items in budgetItems
repeat with i from 2 to itemCount
	set budgetItem to item i in budgetItems
	set theOffset1 to offset of "$" in budgetItem
	set theOffset2 to offset of "]" in budgetItem
	set theTag to "!Budget-" & texts 1 thru (theOffset1 - 2) of budgetItem
	set theAmount to texts (theOffset1 + 1) thru (theOffset2 - 1) of budgetItem
end repeat

cool, thanks - i will try to adapt that. thanks a lot

Darn, this doesn’t seem to work for me. Has this ‘feature’ been removed, @BLUEFROG?

I’m not at my Mac right now so I can’t check. Do you have custom meta-data set to decimal numbers as currency?

No worries, I do have my metadata field set up that way. Strangely, I am able to get it working off and on. It seems to work more often when I select one file, then select more by holding down the shift key and pressing the up/down arrow keys. It doesn’t always work that way, but generally it does. If I select files with just the mouse, it works maybe 10% of the time. :man_shrugging: