Forum Discussion

GlynWilliams's avatar
GlynWilliams
Copper Contributor
Jan 30, 2021
Solved

If statements with multiple conditions

Hello! 

I'd like to manage an If formula to allow multiple text indicators. 

I have a list of cities in on column -- LA, SF, NY, Chicago, etc. I then want to create columns for each city to the right with an X to indicate if that city name showed up in that original cell.

 

I have the basic formula as "=IF(F3="LA", "X") which works fine if the only city listed in that original formula was LA but then if I have multiple cities the cell reads "FALSE."

 

what is the formula to list an X in Each corresponding column to indicate if the citys name was in that original column?

 

  • GlynWilliams 

     

    If you have the flexibility to name cities with the same abbreviation that is in your header, then it's a fairly simple formula: =IFERROR(IF(FIND(G$2,$F3)>0,"X"),"")

    That formula can be copied to every cell in that table and work. But it works when the values in the cell in column F look like this, not when you have the abbreviation in the heading (BOS) but the full name spelled out ("Boston") in the cell being evaluated.

    OR you could spell the name out fully in each case and that too would work. What you need is consistency.

     

    You and I with our more flexible brains are able to know DFW means Dallas/Fort Worth, and a formula could be written to let Excel recognize it as well, or perhaps a table created to for the formula to refer to.

    I guess the question to you is how super sophisticated (i.e., flexible) you want the solution to be.

10 Replies

  • mathetes's avatar
    mathetes
    Silver Contributor

    GlynWilliams 

     

    If you have the flexibility to name cities with the same abbreviation that is in your header, then it's a fairly simple formula: =IFERROR(IF(FIND(G$2,$F3)>0,"X"),"")

    That formula can be copied to every cell in that table and work. But it works when the values in the cell in column F look like this, not when you have the abbreviation in the heading (BOS) but the full name spelled out ("Boston") in the cell being evaluated.

    OR you could spell the name out fully in each case and that too would work. What you need is consistency.

     

    You and I with our more flexible brains are able to know DFW means Dallas/Fort Worth, and a formula could be written to let Excel recognize it as well, or perhaps a table created to for the formula to refer to.

    I guess the question to you is how super sophisticated (i.e., flexible) you want the solution to be.

      • mathetes's avatar
        mathetes
        Silver Contributor

        GlynWilliams 

         

        I think that the answer you got from @Riny_van_Eekelen  is a bit more elegant than mine; one of the delightful aspects of Excel is that there are almost always multiple ways to get to a given solution for any given problem. In this case, as Sergei and I both suggested, you could also have an elaborate table that connected the airport codes (or other abbreviations) with spelled out names. The potential problem with that is that spelling still matters, and humans are not always reliable in their speling.  

  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    GlynWilliams 

    The only question is how Excel will know that NY and NYC; Boston and BOS, etc are the same names? That could be mapping table, or will use same names everywhere, what is the logic?

Resources