on 02-20-2015 9:47 PM
Hi Gurus,
I have looked on SDN but could not find if there is a looping option in Design Studio. What I am trying to do is to loop on result set to find out which entry in Column A is above 20. The moment I put "For" in script window, I get error. Has anyone ever done loops in Design studio?
Thank you for your suggestion.
Raj
Hi Raj,
refer to help at http://help.sap.com/businessobject/product_guides/AAD14/en/ds14SP01_user_en.pdf
-> 27.3.1 Accessing Array Elements
the "loops" are possible by "forEach" statements, like this one:
var i = 2;
var e = "";
var array = DS_1.getMembers("0D_CUSTOMER", 100);
array.forEach(function(element, index) {
if (i == index) {
e = element.externalKey;
}
});
APPLICATION.alert("Element with index " + i + " is \"" + e + "\".");
what you want to do is probably loop at members and ask for data:
array.forEach(function(element, index) {
if (i == index) {
var dataCell = DS_1.getData("MEASURE", {"DIMENSION": element.internalKey });
var value = dataCell.value;
}
});
Does it help you?
Karol
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karol,
Thank you for yoru response! what I am looking for example from the below table, read column B and if it is greater than 3 then get the corresponding value from Column A and put it in a list box. So for below table the output will be green, white, and purple
Column A | Column B | Column C |
Red | 2 | Up |
blue | 3 | Down |
green | 7 | Right |
white | 5 | Left |
purple | 8 | Center |
Hi Raj,
I'm assuming that you are working with the following details:
Copy the following code and replace the technical names of columns A and B (without the '<>' brackets):
//Replace <Column A Technical Name> with the actual technical name of column A. Also adjust the maximum number of members from 300 to whatever value you wish
var Column_A_Members = DS_1.getMembers("<Column A Technical Name>", 300);
var Column_B_Value = 0.0;
//Replace <Column A Technical Name> & <Column B Technical Name> with the actual technical names of columns A&B
Column_A_Members.forEach(function(element, index) {
Column_B_Value = Convert.stringToFloat(Convert.replaceAll(DS_1.getDataAsString("<Column B Technical Name>", {"<Column A Technical Name>": element}),",",""));
if(Column_B_Value >= 3.0)
{
LISTBOX_1.addItem(element.internalKey, element.text);
}
});
I hope this helps.
Thanks and Regards,
Eshwar Prasanna
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.