6 Replies Latest reply: Mar 24, 2017 7:13 AM by Demetrio Cugliari RSS

    If and Or Condition on Scripting

    Demetrio Cugliari

      Hi All,

      I have a problem with an modify on a dashboard.

       

      I have two fields:

      Area and Market

       

      For Area "Nordics and Baltics" and Market "Sweden" i have to insert "Branches",

      For others Market of Nordics and Baltics i have to insert "Importers".

       

       

      To semplify the qvw i have created a small file with inline script and Market Sweden and Finland.

       

      I have replicated the tab of scripting where i have to apply the modify.

       

      The target it's this:

       

      Screen.png

       

       

      In attachment the small file .qvw

       

      Thanks and Regards,

       

      Demetrio

       

      EDIT:

      In attachment the original script code to modify.

        • Re: If and Or Condition on Scripting
          Peter Cammaert

          It's not entirely clear what you are trying to accomplish...

           

          Branches & Importers, are they separate fields whose values you want to show in the same coilumn depending on the Market value?

            • Re: If and Or Condition on Scripting
              Peter Cammaert

              Ah, you picture explains it. You want to include Sweden in the Importers area, but not in the Branches range and vice versa.

               

              How about:

               

              data:

              LOAD * INLINE [

              Area, Market

              Nordics & Baltics, Sweden

              Nordics & Baltics, Finland

              ];

               

              LEFT JOIN (data)

              LOAD Market,

                   IF (Market = 'Sweden', pick(IterNo(), Area, 'Branches'),

                                          pick(IterNo(), Area, 'Importers')) AS mainArea

              RESIDENT data

              WHILE IterNo() <= 2;


              [Edit]: made it match your picture...

            • Re: If and Or Condition on Scripting
              Vishwarath Nagaraju

              Try this?

               

              data:

              LOAD * INLINE [

                  Area, Market

                  Nordics & Baltics, Sweden

                  Nordics & Baltics, Finland

              ];

               

               

              NoConcatenate

              FINAL:

              load

              Area,

              Market,

              if(Market = 'Sweden' AND Area = 'Nordics & Baltics', 'Branches', 'Importers') AS MainArea

               

               

              //if(Market = 'Finland' AND Area = 'Nordics & Baltics','Importers')) as mainArea

               

               

              Resident data;

               

               

              Drop Table data;

              • Re: If and Or Condition on Scripting
                Anil Babu Samineni

                May be here

                 

                data:

                Load * Inline [

                Area, Market

                Nordics & Baltics, Sweden

                Nordics & Baltics, Finland

                ];

                datap:

                Load

                Area,

                Area as mainArea

                Resident data;

                Concatenate (datap)

                load

                Area,

                if(Market = 'Sweden' and Area = "Nordics & Baltics",'Branches','Importers') as mainArea

                Resident data;

                • Re: If and Or Condition on Scripting
                  Demetrio Cugliari

                  Ty All but again don't works.

                   

                  In the first post i have inserted the original script code to modify.

                  I have not only one area (Nordics & Baltics).

                  Initially all Area Nordics & Baltics was Branches.

                  Now only Sweden (of Nordics & Baltics) must be branches.

                  But we have others area importers or Branches.

                   

                  Demetrio

                    • Re: If and Or Condition on Scripting
                      Demetrio Cugliari

                      Ok i solved.

                      I have inserted in Main Table (data) a field Area&Market as Area_Market and then i joined with this new field.

                       

                       

                      LOAD Distinct

                        Area_Market,

                        Market as Market1,

                        if(Area='Austria' OR Area='Benelux' OR Area='Denmark' OR Area='France' OR Area='Germany' OR Area='Iberia' OR Area='Italy' Or (Area='Nordics & Baltics' and Market='Sweden')  OR Area='Poland' OR Area='UK Ireland', 'Branches',

                       

                        

                        if(Area='Balkans' OR Area='Central Eur Distr' OR Area='Eastern Eur Distr' or Area='South Eur Distr' Or (Area='Nordics & Baltics' and Market<>'Sweden')  or Area='Ukraine  Moldova', 'Importers')) as main_area

                      Resident data;