0

EX. https://docs.google.com/spreadsheets/d/1CwFXSwIgnPdMocbrhTFZbEPRyXZUiovvWNy9MtOagxE/edit#gid=0

I wanted to compare two column "fix version" and "Affected version" and return the result bases on below logic.

if the fix version tag = affected version → pre-release

if the fix release tag > affected version → post-release

I am new to Google Script, so how can I do that using Google Script?

1

Why not using simple formula? Thy this formula, paste it in any free cell (row2):

=ARRAYFORMULA(if(A2:A=C2:C,"pre-release",if(C2:C>A2:A,"post-release","other")))
0

Looking at your solution, I can see you are trying to parse the string in the column. Try this. put 'release' in one column and the version number in another and then put them together in the 3rd column. So you might have A1 as 'release' and B1 20160504 and then in C1 you concatenate them. Now in E1 you can use B1 using a comparison considering it will be a number. Of course, you would also do this with your fixed version. You can HIDE the A and your B column in order to make it look cleaner. Of course, you would also hide your extra columns for the fixed side as well.

0

I created a new script file in your project with some example code.

/**
 * Compare the affected and fix versions
 * @param {cell} affected version
 * @param {cell} fix version
 * @return whatever
 * @customfunction
 */
function COMPAREVERSIONS(affected, fix) {
  return (affected === fix) ? 'pre-release' : 'post-release';
}

Not exactly sure what this is supposed to do, but hopefully this gives you a little bit of an idea about how to create a script that will more closely solve your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.