Mapping(?) a value in Bases

I’m doing a weapon database with a Base, and i have a property in every page of a weapon called origin. It’s a all lowecase, no space, name of the country, like southafrica. I want it to display something like “South Africa”.

The only way i can think of of doing this is by having a table or an array. I don’t know if it’s possible, but i hope so.

A formula like this:

[
["South Africa", "southafrica"],
["Saint Kitts and Nevis", "saintkittsandnevis"],
["Bosnia and Herzegovina", "bosniaandherzegovina"],
["Democratic Republic of the Congo", "democraticrepublicofthecongo"]
].filter(value[1] == origin)[0][0]
1 Like

Huh, i didn’t know key-value arrays could be done in Obsidian.

When i put this in my Base, it only shows “South Africa”, but it doesn’t show anything for other ones like “argentina”.

I forgot to mention, but only some (ones that have two words mainly) values need to be replaced. The other ones can be handled using title()

Oh of course. I wasn’t thinking. You can add a fallback for all the origins you didn’t list, and make it title case.

Try:

[
["South Africa", "southafrica"],
["Saint Kitts and Nevis", "saintkittsandnevis"],
["Bosnia and Herzegovina", "bosniaandherzegovina"],
["Democratic Republic of the Congo", "democraticrepublicofthecongo"],
["", origin]
].filter(value[1] == origin && origin)[0].map(if(value, value, origin.title()))[0]

Works perfectly!