3 Replies Latest reply on Apr 26, 2016 6:09 AM by Julio Moyano

    I need select records with two or three conditional

    Julio Moyano

      HI everybody,

       

      I need to select records with condition variables.

      for instance: I have two column (House and Age) and I need to create "type house"

       

         

      HouseAgeType house
      207134 to 12with kids
      2071313 to 17with kids
      1002013 to 17not kids
      1002018 to 24not kids
      33200 4 to 12with kids
      3320035 to 40with kids
      1333335 to 40not kids

       

      I need select:  IF house X  has Age 4 to 12 OR 13 to 17 = 'with kids'

      ELSE 'Not kids'

       

      Other examples: IF house X has not Age 35 to 40 OR 18 to 24 OR 13 to 17 OR 4 to 12  = 'wIth old people"

       

      I need to select different houses according to people lives in there

       

      Can you help me?

       

      thank you!

        • 1. Re: I need select records with two or three conditional
          Rishabh Dhingra

          Hi Julio,

           

          As far as I can understand your question, all you need to do is create a calculated field for House Type based on the conditions you just mentioned. Then you can use this field as a quick filter so that the user could select the house type he is interested in.

           

          Is this what you are looking for?

           

          Thanks,

          Rishabh

          • 2. Re: I need select records with two or three conditional
            Tableau kumar

            We can use the "And" or "Or " Operators in the "Conditional Statements.

             

            Let me write basic query here.

             

            if   ( [House]="1234" and [Age] ="1 to 10" ) or ( [House]="1234" and [Age] ="11 to 20" ) then "Grp -1"

            elseif  ( [House]="1235" and [Age] ="15 to 25" ) or ( [House]="1236" and [Age] ="40 to 60" ) then "Grp -2"

            ........

            end

             

             

            another Example:

             

            if (attr(Year([Order Date])) = 2011 and  sum([Sales])>10000)   (attr(Year([Order Date])) = 2012 and  sum([Sales])>15000)or  then "Good"

            elseif (attr(Year([Order Date])) = 2011 and  sum([Sales])>20000)   (attr(Year([Order Date])) = 2012 and  sum([Sales])>55000)or  then "Better"

             

             

            If you want to learn more about how to write condition in Tableau, go through the following Link.

            Writing Conditions in Tableau

             

             

            Best Regards

            Kumar

            • 3. Re: I need select records with two or three conditional
              Julio Moyano

              Hi Kumar,

               

              Thanks for you response. But I can't do it.

               

              I wrote:

              IF  [Codigo Hogar]= '280812' AND ([Tramo Etareo 2] = '4 a 12' OR [Tramo Etareo 2] = '13 a 17') THEN '1'

              END

               

              The variable are string

               

              But in data base appear null

               

              Other issue is I have many 'codigo hogar'. There is some form I can do this to every 'codigo hogar' once and not write for each one.

               

              thank you!