Calculating a formula with relative cell references and providing row/col context #1149
Replies: 2 comments 3 replies
-
Hi @qcurtemanjc, thanks for reaching out. If I understand your use case correctly, you would like to perform the calculation outside your data sheet. The The obvious solution is to iterate through all the rows: for (let rowNum = 1; rowNum < 100; rowNum++) {
console.log(hf.calculateFormula(`=B${rowNum}="Yes"`, 0));
} But you can also use the array arithmetic feature to calculate that formula for the whole column at once and obtain the result in the form of an array. const resultArray = hf.calculateFormula('=ARRAYFORMULA(B1:B99="Yes")', 0); or const resultArray = hf.calculateFormula('=ARRAYFORMULA(B:B="Yes")', 0); Let me know, if this solution works for you ;) |
Beta Was this translation helpful? Give feedback.
-
Hey @sequba Thank you for the response! I have been informed that Hyperformula's "Named Expressions" module might be able to help me achieve what I'm looking for (https://hyperformula.handsontable.com/guide/named-expressions.html#available-methods) Essentially, I would like to be able to feed a function a formula and a delta and receive the formula translated to a new position based on the delta. The example I provided above was only one example, for my use case, any formula can be used and so I need a solution more flexible than Another use case example might be like this: Formula: I tried to add this formula to Hyperformula's "Named Expressions" module but it said Does Hyperformula have a module that can do this? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have a use case where I have a formula like so
=$B1="Yes"
and I would like the cell references to adjust to their relative value based on the row/col I'm on. For example:=$B1="Yes"
=$B2="Yes"
I was hoping I could use the
calculateFormula
function for this but it looks like I cannot add row/col context and I haven't been able to find any helper function that can convert a formula relative to a row/col provided. Can you help with this?For more context, I am trying to replicate this behavior in Google Sheets

Please let me know if you have any more questions, thanks!
Beta Was this translation helpful? Give feedback.
All reactions