Home > OS >  IF statement being inconsistent
IF statement being inconsistent

Time:03-11

I have a google sheets file that has A Lot of sheets, most of them have data that's pulled from other sheets.

Let's say I have a sheet called Team 1 that has the data for Player 1, Player 2, Player 3 etc.
Now I want to pull the data for each Player into a different sheet, AKA pull his data from Team 1 sheet into a new sheet called Player 1

I used =FILTER normally → =FILTER('Team 1'!A:CC, 'Team 1'!B:B="Player 1")
And this works very well.. BUT I had an ingenious idea to avoid #N/A Error in case of the player not having any data, so I cam up with this:

=IF(
    EXACT(
        'Team 1'!B:B, "Player 1"),
    
    FILTER(
        'Team 1'!A:CC, 'Team 1'!B:B="Player 1"),
        
    "This Player has no data")

Which works well.... sometimes...
I do not understand why this IF statement is inconsistent.

Let's say Player 1 has data in Team 1 and I want to pull it into Player 1 sheet.

If I put the formula in Row 2, it returns False: enter image description here

But if I put the formula in Row 3 it returns True: enter image description here

Also another weird thing, it used to work well if I put the formula in row 2 in one of the sheets but not the others.

I do not understand why any of this happened as it makes no sense.. to me at least.

Edit1: I didn't enclude the Team 1 sheet which was important as my problem wasn't with the IF per se, but my problem was with EXACT.

Apparently EXACT depends on the campared data to be on the same row/cell
If we put the same formula in A1 to A4 in Player 1 Sheet: enter image description here

CodePudding user response:

To avoid the N/A error in case of an empty output, wrap the FILTER() in an IFERROR() or IFNA()

=IFERROR(FILTER('Team 1'!A:CC, 'Team 1'!B:B="Player 1"), "This Player has no data")

and see if that works?

  • Related