Skip to Content

Need option to convert numeric to text

I want to know if there is any option to convert numeric in design studio chart to text using if else condition.

for example if posting period =1, the it should display Jan

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • May 22, 2017 at 04:14 PM

    Hi - are you using Design Studio (not "ByDesign Studio")?

    Have you searched? When I search, I find these:

    https://archive.sap.com/discussions/thread/3958010

    https://blogs.sap.com/2014/07/10/design-studio-13-scripting-example-to-convert-number-to-date/

    If these do not help, please share version, support pack, and data source.

    Tammy

    Add comment
    10|10000 characters needed characters exceeded

  • May 23, 2017 at 01:48 AM

    Hi Bhargav,

    It sounds like you want to convert a numeric key value to a corresponding text description. This is best achieved via an array lookup as per the example I have given in the first discussion link Tammy has referenced.

    Here is a code sample to illustrate the technique specific to your case of converting period numbers to month descriptions:

    var period = 1;
    var monthArray = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
    
    var monthText = monthArray[period - 1];  // Lookup text of month based on array index
    
    APPLICATION.alert(monthText);
    
    

    Regards,

    Mustafa.

    Add comment
    10|10000 characters needed characters exceeded

    • Mustafa Bensan Bhargav Ram Rajulapati

      Hi Bhargav,

      I am surprised to learn that you cannot maintain the text of the Posting Period in BW. Can you clarify why this is the case? For your scenario, the recommended approach is definitely to maintain the text in BW.

      The only workaround would be to use the combination of the Community SDK Data Iterator and Bring Your Own Data Source components, similar to the techniques described in the following blog:

      https://blogs.sap.com/2016/03/10/design-studio-16-data-blending-and-what-if-analysis-with-data-iterator-bring-your-own-data-source/

      Basically, you would need to use the Data Iterator to loop through the data result set and substitute the Period Name for the Period Number and then create a new data source with the BYOD component which would then be assigned to your chart. However, I advise against this approach because you will need to replicate this for every application that uses the same BEx Query. You should definitely maintain the texts in BW.

      Regards,

      Mustafa.