Skip to content

Converting Money In Obsidian Data View

Hey friends! 😊

I've been trying to keep track of how much I spend on subscriptions every month, and I found a cool way to see it all in my local currency (NIS) using Obsidian. I'm no techie, but I thought sharing this might help someone in the same boat.

Here's How My Table Looks:

NameBilled DateUSDNIS
Apple oneAugust 01, 20231243
TLV Gym~55200
YouTube PremiumJune 21, 2023932
Open AI172075
Subscription Services---

What I Did ​

  1. Listed My Subscriptions: I made the above table in Obsidian with all my subscriptions and how much they cost in USD.

  2. Totaling It Up: I used some code to add up all those numbers in the USD column. Think of it like a calculator right inside Obsidian.

  3. Currency Conversion: This was the exciting part! I used a free online tool to convert my total spending from USD to NIS. Here's the code I put in my note (you can just copy and paste it):

javascript

const subscriptions = dv.pages('#Subscriptions'); // Change this to your tag for subscriptions
let total = 0; // This will hold the total amount in USD

for (let i = 0; i < subscriptions.length; i++) {
  const usd = subscriptions[i].usd; // Getting the USD value from each subscription
  if (usd) total += Number(usd); // If USD value exists, add it to the total
}

fetch('https://open.er-api.com/v6/latest/USD') // Change 'USD' to your currency
  .then(response => response.json())
  .then(data => {
    dv.paragraph(`Total (NIS): ${total * data.rates.ILS}`); // Change 'ILS' to your currency code
  });

Code Explanation ​

// This line looks at the USD column in the table.
Const usd = subscriptions[i]. Usd;

// This adds the USD value to the total if it's there.
If (usd) total += Number (usd);

What to Change ​

  • #Subscriptions: Change this to the tag you're using for your subscriptions.
  • 'USD' and 'ILS': Change these to the currency codes you want to convert from and to.

And voila! Now I can see how much I'm spending in my local currency, and it's all right there in my Obsidian notes.

I know this might seem small, but it's made visualizing my spending so much easier. If you're like me and want to keep an eye on your subscriptions, maybe this can help you too.

If you have any questions, just ask. And if you're a coder, please don't hesitate to correct me

Happy budgeting, everyone! 🎉