2 Replies Latest reply on Sep 5, 2018 4:58 PM by shall

    How to embed a single quote in URI builder

    shall

      Hi all,

       

      I am trying to generate a URL attached to an element to a Power BI report. Power BI supports URL-embedded filtering with very specific rules. I am very close to the outcome I would like, but I need to be able to wrap the value in single quotes for Power BI. However, these get interpreted in the PI URI builder a delimiters for an attribute.

       

      Needed: ...base URL...?filter=FilterAPI eq 'API' where 'API' is a value stored on the element.

       

      I have tried

      • ...base URL...?filter=FilterAPI eq "'API'" (that is double quote, single quote, API, single quote, double quote) and I get the API value wrapped in double quotes ("string")
      • ...base URL...?filter=FilterAPI eq ''API'' (that is single quote, single quote, API, single quote, single quote) and I get the string API by itself
      • ...base URL...?filter=FilterAPI eq '''API''' any number more than 2 single quotes balanced on API just gets me the value for API
      • Wrapping a single quote in double quotes results in an error
      • Used single quote ASCII value (%27). The parsing does not quite work right.

       

      Below is my closest arrival to what I want.

       

      pi vision url.png

      All I need is the single quotes wrapping the 3501724819 number (which is a string in Power BI). Worst case, I can change the data type of the FilteredAPI to be a number which would allow the URL shown to work, but I would prefer to use the data as stored, if possible.

       

      Thanks,

      Scott

        • Re: How to embed a single quote in URI builder
          Eugene Lee

           

          In your API attribute, use a string builder like such

           

          The value is double quote, single quote, 3501724819, single quote, double quote.

          1 of 1 people found this helpful
            • Re: How to embed a single quote in URI builder
              shall

              Thank you for your reply. The API attribute changes per element, so I need to be able to reference correct one for each element. Then, I could apply these changes to the element template. I like your idea of using the string builder, so I added a second attribute to point to the current API attribute and manipulate the string there. It took some iterations on syntax in the data reference, but I did get it to work. In string builder, the line breaks help the tool determine which items go together. Thank you!

               

              single quote success.png

              String builder syntax is:

              double quote, single quote, double quote

              API

              double quote, single quote, double quote

               

              single quote success 2.png