4 Replies Latest reply: Mar 16, 2017 10:07 AM by Zied Ahmed RSS

    condition in script

    Zied Ahmed

      I need to do the condition :

       

      i have four fields:

      car

      date

      parc

      country

      if i have one car in 2 differents parc in the same date i need to put these cars in flags

      how to do it thanks 

        • Re: condition in script
          Arockiya Selvan A

          Hi,

           

          Try this...

           

          Map_Count:

          Mapping LOAD car&'-'&date as Key,

                                       Count(parc) as Count

          FROM File

          Group By car, date;

           

          Main_Table:

          LOAD *,

                     If(Count>1,1,0) as Flag;

          LOAD car,

                      date,

                      parc,

                     Applymap('ap_Count',car&'-'&date) as Count,

                      country

          FROM File;

           

          Pls let us know if your requirement is different.

          • Re: condition in script
            Chhavi Singhal

            Hi Zied,

            You can try this

             

            Temp:

            LOAD Car,

                 Date,

                 Parc,

                 Country

               

            FROM

            <<Your data source>>

             

             

            Count1:

            LOAD Car,

                 if(Count(DISTINCT Parc)>1,1,0) as Flag

                  Resident Temp  group by Date,Car;

             

             

            In your expression, you can write if sum(Flag)>0, 1,0

             

            I hope this helps.

             

            also, if you share the QVW with us, It would give a better clarity.

            PFB: screenshots for better clarity

            data.PNG

             

            output.PNG

            • Re: condition in script
              Andrey Khoronenko

              Hi,

               

              Can be like this if I understood the task correctly?

               

              Table1:

              LOAD*Inline

              [date, car, parc, country

              01.01.2017, car1, parc1, country1

              02.01.2017, car2, parc2, country2

              03.01.2017, car3, parc3, country3

              03.01.2017, car3, parc2, country3

              04.01.2017, car1, parc1, country1

              04.01.2017, car1, parc6, country1

              04.01.2017, car1, parc2, country1];

               

              Left Join

              LOAD

              date,

              car,

              If(Count(parc)>1, 1, 0) as Flag //

              Resident Table1

              Group By date,car;

               

              Result

              5.jpg

               

              Regards,

              Andrey