Calculating and Pasting Percentages

I'm new to Keyboard Maestro. Each pay period I'd like to run a macro that calculates and pastes certain percentages of my total income in an Evernote table.

For example, if I have $1000 in the clipboard (as income), how can the macro calculate and paste the total amount of the percentages as below?

  • Total Income (100%) $1000
  • Taxes (25%) $250
  • Expenses (35%) $350
  • Charitable Giving (10%) $1000
  • Misc. (30%) $300

Thanks for any help you can offer. I appreciate it.


Hi Wayne,

Here's a sample macro that should get you started. It takes the numeric figure currently in the clipboard, removes any non-digit characters from it for the purposes of calculation, saves that figure to a variable, then uses that variable for all the calculations you describe using the Calculate Format token and pastes it:

Calculate and Paste Percentages.kmmacros (2.2 KB)


You can adjust the format of the text pasted in the Insert Text by Pasting action directly. Feel free to report back with any questions.

1 Like

Really do appreciate the reply. I imported the macro and I assigned it a trigger. I made sure to have an amount in my clipboard, but the macro didn't run.

Like I said, I am a newbie. Sorry if this is simple!

I suspect it did run. I just tried it myself and was confused for a second though. The original macro that gglick uploaded doesn't display it in a window, it just inserts the text into wherever your cursor is. Try it with a text editor open :slight_smile:

@gglick has shown you how to do this with KM.

I'd like to suggest an alternative.

As you probably know, Evernote Tables are very limited, and do NOT offer:

  1. Any means to calculate cells like Excel
  2. Any means to automate get or set of a specific cell in the Table

However, Evernote does a very nice job of inline display of an Excel file.

For these reasons, I would suggest that you maintain your data in Excel, and store that file in an Evernote Note. Then get and set of data in the Excel file can be highly automated using both KM, and AppleScripts run from KM. You can even automate the opening of the Excel file in the EN Note.

If this sounds interesting, let us know and I'll share more.

1 Like

If you're new to KM, then you might not know that imported macros are disabled by default, and won't run unless you enable both the macro group they're in and the macro itself, so I'd start by making sure the macro is enabled and is in an enabled macro group. Assuming that's the case, @vincent_ardern is right in that the macro I posted is set to paste the results, not display them. If you want to display them the way I did to make sure it's working, just change this setting in the Insert Text action:

1 Like

This worked great! Mind two follow-up questions?

  1. How can I get each line in its own paragraph? Right now, they're all on one line/paragraph. Not sure how to insert a line break in your macro.
  2. When the macro removes any non-digit characters from it for the purposes of calculation, it removes decimal points (needed for cents). Can the decimal stay?
    So appreciate your help!

Glad to hear that, and no problem.

  1. In the KM editor, you can manipulate the text shown in the Insert Text by Pasting action just as you would in any other application, so all you need to do is move the input cursor to the end of a line and hit Return like normal:

  1. Yes, easily. Just modify the regex used in the Search and Replace action from this:


to this:


so that it looks like this:

Gabe, that worked flawlessly. Thanks so much.


1 Like