Search code examples
if-statementgoogle-sheetsgoogle-sheets-formulaarray-formulasgs-vlookup

Arrayformula to check if column contains text and pull the number next to it. Google Sheets


In desperate need of some assistance with this! Wasn't sure how to title this question...

SAMPLE SHEET - CLICK ME! :)

In SupportingSheet!H1 I have the following formula:

=ArrayFormula(if(G1:G<>"", IF(DASHBOARD!N2<>"", G1:G/DASHBOARD!$P$2-filter(DASHBOARD!O1:O100,REGEXMATCH(DASHBOARD!N1:N100,E1:E100)),G1:G/(DASHBOARD!$M$3)),))

The part I struggle with is:

G1:G/DASHBOARD!$P$2-filter(DASHBOARD!O1:O100,REGEXMATCH(DASHBOARD!N1:N100,E1:E100))

It needs to divide two numbers and then subtract another number. I can't seem to get this formula to pull the correct number. It needs to check if the text in E1:E100 exist in DASHBOARD!N1:N100, if yes, pull the number from DASHBOARD!O1:O100.

For example, text in SupportingSheet!E1 can be found in DASHBOARD!N2, hence it needs to pull the number from DASHBOARD!O2.

Column SupportingSheet!J has the actual end result that a formula needs to produce.

It doesn't look like Regexmatch works as an Arrayformula and I am not sure how to go about it.

Please note, that text in SupportingSheet!E1:E is not always identical. Often it will have a random number of "space" at the end (long story...). That is why Regexmatch was a perfect option until I realised it didn't work.

Please let me know if further clarification is needed.

Below is an image of the random spaces (non-printable characters) at the end.

enter image description here


Solution

  • use:

    =ARRAYFORMULA(IF(G1:G="",,IF(DASHBOARD!N2<>"", 
     IFNA(G1:G/DASHBOARD!$P$2-VLOOKUP(E1:E1000, DASHBOARD!N1:O100, 2, 0), 
     G1:G/DASHBOARD!$M$3))))
    

    0