on 05-22-2017 3:29 PM - last edited on 02-03-2024 10:29 PM by postmig_api_4
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bhargav,
The reason for the behaviour you have observed with the alert pop up is that you have literally copied the code I supplied, intended as guidance, without adapting it for your specific scenario.
Please answer the following questions to clarify your requirement:
1) What type of data source is assigned to your chart: BW BEx Query, HANA View or Universe?
2) If I understand your requirement correctly, you want to show the text "Jan", "Feb", "Mar" as the labels in the chart x-axis instead of "1", "2", "3"? If that is the case, then these texts should be available from the data source assigned to the chart. The approach will depend on your answer to Question 1 above about which type of data source you are using.
Regards,
Mustafa.
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:
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.