3 Replies Latest reply on Oct 23, 2018 11:29 PM by lei.chen.0

    How can I create a dropdownlist to filter data?

    Penn Wang

      Hi Everyone,

       

      I'm very new to Tableau.

       

      For example, I have a row [food] with data "Apple01", "Grape01", "Lime01", "Potato01", "Onion01" and "Carrot01" and other random things.

       

      Now I want to create a filter with three options, "Fruit", "Vegetable", and "Other".

       

      When choosing "Fruit", I want to see data starts with "Apple", "Grape", and "Lime" only.

      When choosing "Vegetable", I want to see data starts with "Potato", "Onion", and "Carrot" only.

      When choosing "Other", I want to see all the things that don't include in the previous two options.

       

      The filter formula that I am writing is like this, something is wrong. Any help would be much appreciated.

       

      IF STARTSWITH([food], 'Apple')

      OR STARTSWITH([food], 'Grape')

      OR STARTSWITH([food], 'Lime')

      THEN 'Fruit'

      ELSEIF STARTSWITH([food], 'Potato')

      OR STARTSWITH([food], 'Onion')

      OR STARTSWITH([food], 'Carrot')

      THEN 'Vegetable'

      ELSE 'Other'

      END