Search code examples
google-sheetsformulaarray-formulas

Google Sheets IF&AND functions giving contradicting results


I am having some trouble with a formula in Google sheets. For me it just doesn't make any sense, why it is working in one place and not another. So, here is my sample Spreadsheet

My aim is to duplicate results in column D to column E, but with a filter built-in which filters on column A, company.

This is the formula which is working fine:

=ArrayFormula(TEXTJOIN(", ",TRUE,Unique(IF(B4=B:B,C:C,""))))

And I need the IF part to take another condition, which is A=A:A

=ArrayFormula(TEXTJOIN(", ",TRUE,Unique(IF(AND(A4=A:A,B4=B:B),C:C,"NOT GOOD"))))

So I thought AND will do it as it does elsewhere. But in this particular case, this just doesn't seem to work and gives an error every time. I checked and the logic seems fine based on this (giving the expected results):

=ArrayFormula(TEXTJOIN(", ",TRUE,Unique(IF(AND(TRUE,TRUE),C:C,"NOT GOOD"))))

The strange part is that if I select the IF foormula, it tells me that both of the conditions in AND are true, but it still gives me the FALSE result. showing true, but results in false

I am having a hard time understanding why this is the case?? I hope you could help. Thank you in advance.


Solution

  • I made a new tab called MK.Help and placed this formula in cell B2:

    =UNIQUE('Combined Job Catalogue'!A3:B)
    

    Then this formula in cell D3 and dragged down a couple dozen rows:

    =IF(C3="",,JOIN(", ",UNIQUE(FILTER('Combined Job Catalogue'!C:C,'Combined Job Catalogue'!A:A=B3,'Combined Job Catalogue'!B:B=C3))))
    

    Was that the goal?