2 Replies Latest reply: Aug 8, 2018 5:31 AM by Vincent Bellanger RSS

    Check a character at a certain position

    Vincent Bellanger

      Greetings,

       

      I have a table like this

      Server Name
      rect4156ezr

      rect9685erz

      azed1562aze
      deer4567ezz

       

      And i want to filter to get only those who have an e at the 9th position on their name, i tried with index("Server Name" ,'e')=9 but i doesn't work if e is present multiple times.

       

      Thanks for answers!

        • Re: Check a character at a certain position
          Petter Skjolden

          The Index function will not always work in the way you have been thinking. Mid() function is a better and more efficient approach.

           

          Mid("Server Name",9,1) = 'e')

           

          This will do a direct check of the character at the ninth postion without doing a search. Index like you have used will not match on a server name that have one or more 'e' characters before the ninth position even if the ninth character is an 'e'.

           

          Are you doing this in your load script or in a sheet in a visualization table?

           

          If in the load script it would be:

          LOAD

              ....

          WHERE

              Mid("Server Name",9,1)='e';

           

           

          If in a visualization table you do it - depends on which dimensions you have - but making a dimension that only includes the server names that have e in the 9th position would be an option:

           

          =If( Mid("Server Name",9,1)='e', "Server Name")