5 Replies Latest reply: Feb 7, 2011 11:01 AM by Vlad Gutkovsky RSS

    Script If ApplyMap

      Hi

      In the QV script I have the below 2 functions that seem to work ok, but I'm actually trying to combine them so I can put a list feild on the page that will drill the charts accordingly.

      ApplyMap ('ratm', [Rate Code] )as [Structured or Unstructured],

      if(mid(Opics,6,2)<>'AL','Unstructured','Annuity') as Annuity,

      What I would like it to say is , if the mid digits in 'OPICS' is AL call it Annuity, if its not go to map and apply accordingly , call this result [Structured/Unstructured]

      I have tried many combinations but I think it should look something like this but its just not working

      if(mid(Opics,6,2)<>'AL','Annuity',ApplyMap(ratm',[Rate Code])) as [ Structured or Unstructured],

      Can anyone please help ?

      Thanks Anne

       

       

       

       

       

       

       

       

       

       

       

       









       

       

       

       

       

       









       

       

       

       

       

       









       

       

       

       

       









       

       

       

       

       















       







        • Script If ApplyMap
          Vlad Gutkovsky

          Assuming you copied-and-pasted verbatim, I think it's just a syntax error. Try this instead:

          if(mid(Opics,6,2)='AL','Annuity',ApplyMap('ratm',[Rate Code])) as [Structured/Unstructured]

          If this doesn't work, then most likely you have a problem with your map. Please provide more details on what's failing exactly.

          Regards,

            • Script If ApplyMap

              Hi Vlad,

              This worked perfect , am I right to say my only issue with how I wrote is it by using <> rather than = ?

              Thanks

              Anne

                • Script If ApplyMap
                  Vlad Gutkovsky

                  Well no, not really, that was just a personal preference on my part. Your problem is that you were trying to make the output 2 fields instead of 1 (called [Structured or Unstructured] and Annuity). For your purposes this doesn't work.

                    • Script If ApplyMap

                      So it was the "OR" in the Structured Unstructured column ?

                      I should not use these and try / instead ?

                      Thanks

                        • Script If ApplyMap
                          Vlad Gutkovsky

                          Anne,

                          You were trying to create a field called [Structured or Unstructured]. Then, in you IF statement, you were using the word "Unstructured" (having absolutely nothing to do with the field you created). It doesn't work that way. You can apply a map conditionally, it just has to be done within 1 declaration. Or with a preceding load. For example:

                           


                          LOAD
                          if(myfield3='ABC','ABC',myfield2) as finaloutput
                          LOAD
                          applymap('mymap',myfield1) as myfield2
                          ;


                          Regards,