Forum Discussion

MadhuraK's avatar
MadhuraK
Data Storage
04-07-2022

To print string/text

Hello,

Can someone help me to understand how can we print string/text in Sisense? Which command can we use? How to use it?

5 Replies

Replies have been turned off for this discussion
  • Please give an example.  Is this text from an ElastiCube/LiveModel or simply text you wish to 'hard code' on a dashboard.

    Regards, Jim

    • MadhuraK's avatar
      MadhuraK
      Data Storage

      Hello Jim,

      Thank you for quick response. I want to print simply text. 

      Example: Case When Sales<0.3, then it should print text "Low".

      I have multiple such conditions where text varies basis sales percentage. 

  • harikm007's avatar
    harikm007
    Data Warehouse

    MadhuraK ,

    If I understood the problem correctly, there are 2 options I was able to find:

    1. Use Advance Formula plugin - https://www.sisense.com/marketplace/advanced-formula/

    2. Use numbers in formula and replace it with required text using script.

    For example : Case When Sales<0.3 then 1 else 0 end. Then replace 1 and 0 with required text using script.

    Here is an example for how to replace string in pivot2 - https://community.sisense.com/t5/build-analytics/pivot2-replace-a-value-in-a-specific-value-in-another-column/td-p/2790

    -Hari

     

    • Silutions's avatar
      Silutions
      ETL

      Hari,

      Seems like the widget script it the best approach, but I think you noted in the script you created for me that it doesn't work on numbers from the values panel.  I think that is what MadhuraK needs.

      MadhuraK - if you change Hari's script slightly to this:

      //Replace cell values with another value in a specific column
      //Works on numbers from VALUES Panel.  Does not work values from ROWS panel.
      widget.transformPivot(
          {
              type: ['value']
          },
          function setCellBackground(metadata, cell) {
      columnIndex = 2  // SET COLUMN INDEX TO CORRECT COLUMN. NOTE: INDEXES START WITH 0
      if(metadata.colIndex == columnIndex)
      {
      cell.style = cell.style || {};
      if(cell.content < '0.3')  // REPLACEMENT LOGIC STARTS HERE
      cell.content = 'Low'
      else if(cell.content < '0.5')
      cell.content = 'Med'
      }
          }
      );
       
      This will work if you only need to replace the value in a single column in Pivot2.
      - Jim
      • MadhuraK's avatar
        MadhuraK
        Data Storage

        Hello Hari and Jim,

         

        Thank you for the response. I tried the widget script and could print desired string. 

        However I could not download the report in excel/pdf format. Is there any way to download the report?