3 Replies Latest reply: Mar 10, 2016 10:56 AM by Nik Bach RSS

    Blacklist implementation in script

    Nik Bach

      Hello experts,

      I need to implement a kind of “blackist” with some logic behind.

      I’ve already tried some stuff, but it doesn’t work as required still.

       

      The requirement:

      We have a SalesData table and a Blacklist table.

      Screenshot03-Results.png

       

      If a customer is in the blacklist table, we need to check the year & month since he is blacklisted. From that date on all of his records should be removed from the table. It must be done in script, playing with the filters is not an option ; )

       


      E.g. 101 John Smith is blacklisted since 02-2015. All records after 02-2015 will be removed from the table. Only the record from 01-2015 will stay, because he was not blacklisted on that date. The customer 105 Joshua Sleedge will be removed, too.

       

      I’ve setup an example with all data already in place, so you can play with it.

      In the file “01_HowTo_Blacklist-data_load_only.qvw” the data is just loaded. – nothing to do there

      In the file “02_HowTo_Blacklist-data_modelling.qvw” we should remove the blacklisted customers. In the load script, if possible (but without playing with filters)

       

      Thanks

      Nik

        • Re: Blacklist implementation in script
          Puttemans Johan

          Hi Nik,

           

          Please try like below.

           

          MAP_blacklist:

          MAPPING LOAD

            CustomerID,

               //CustomerName,

               Year&Month as date

          FROM

          [C:\Users\rfn7501\Desktop\QV varia\Tab_Blacklist.xlsx]

          (ooxml, embedded labels, table is Tab1);

           

           

          100:

          LOAD Team,

               CustomerID,

               CustomerName,

               Category,

               Product,

               Year,

               Month,

               Sales,

               Profit,

               Applymap('MAP_blacklist',CustomerID, 202012) as dateblacklisted

          FROM

          [C:\Users\rfn7501\Desktop\QV varia\Tab_SalesData.xlsx]

          (ooxml, embedded labels, table is Tab1);

           

           

          NoConcatenate

           

           

          200:

          LOAD *

          RESIDENT 100

          WHERE Year&Month < dateblacklisted;

          DROP TABLE 100;

           

          Kind regards,

           

          Johan

          • Re: Blacklist implementation in script
            Stefan Wühl

            Or maybe using a common key

             

            Temp:

            LOAD * FROM SalesData;

             

            LEFT JOIN (Temp)

            LOAD Blacklist_CustomerID as SalesData_CustomerID,

                       Blacklist_Year,

                       Blacklist_Month

            FROM Blacklist;


            Result:

            NOCONCATENATE

            LOAD *

            RESIDENT Temp

            WHERE MakeDate(SalesData_Year,SalesData_Month) < RangeMin(MakeDate(Blacklist_Year,Blacklist_Month), Today(1));

             

            DROP Table Temp;

             

            edit: RangeMin...