Hi guys!
What I’m trying to do
For some notes, I would like to use a function that calculates on property values given in the yaml frontmatter of the notes. The function should only work within the file and calculate based on a condition given by the data.
PropertyString: "A"
PropertyNumber1: 10
PropertyNumber2: 20
I would like to use a function that is active as soon as all relevant properties are provided in the frontmatter. The function should operate based on a condition given by PropertyString
. I try to outline what it should do below:
// Look if all neccessary data is provided in yaml frontmatter:
// 1. `PropertyString` 2. `PropertyNumber1` 3. `PropertyNumber2`
// Pull those and operate conditionally based on 1. `PropertyString`
function MyFunc() {
if (PropertyString === "A") {
result = PropertyNumber1 - PropertyNumber2;
} else if (type === "B") {
result = PropertyNumber2 - PropertyNumber1;
}
}
After the function is applied, I would like to use the result to make further calculations and in the end have a neat table of results…
Things I have tried
I tried to get this done using normal dataview using the choice()
function but I was not successful. Would you please help me to get my foot in the door with dataviewjs
?
Cheers!