cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Analytics Cloud - Application Design : Get Variable Value

0 Kudos
5,185

Hi everybody,

In SAP Analytics Cloud Application Designer, I would like to get a variable value to a text field. I know that through getVariables(), I can print the variables themselves, but I'm interested in the variable values, for instance a date.

Does anyone have experience with how this can be done?

Thanks in advance.

Mathias

Accepted Solutions (0)

Answers (6)

Answers (6)

JBARLOW
Active Contributor

This code worked for me (I found it elsewhere, so don't fully understand it - but it works)

var variable = tbl_main.getDataSource().getVariables()[0];
var value = tbl_main.getDataSource().getVariableValues(variable)[0];
switch (value.type) { case VariableValueType.Single: var singleValue = cast(Type.SingleVariableValue, value); console.log(singleValue.value);
txt_box.applyText(singleValue.value); }

saurabh_sonawane
Active Contributor

Hi,

you can try this.

Create a chart and assign only one dimension = variable (it has to show only one selected value from the BW )

variable should come from the BW as a dimension.

var res = Chart_1.getDataSource().getMembers(" variable");

text.applytext(res);

Thanks,

Saurabh S.

keinhoff
Participant

Hi Mathias,

do you already have a solution for this as I am also struggeling with this problem. I also would like to display the values from the variables of an BW Query to show the selected dates.

foekenm : In the Handbook there is no description concerning this. Only for setting variables in scripting or removing and copying variables values between two different datasources. 😞

mfoeken
Active Contributor

Hi Mathias,

Did you already check in the Analytics Designer Handbook?

https://www.sapanalytics.cloud/analytics-designer-handbook/

Kind regards,

Martijn van Foeken | Interdobs

matup_121
Newcomer
0 Kudos

Hi,

long time since opening, but i did this to show the variable selection in a Textfield.

Depending on the variable type.

I found this script somewhere and adaopt it to my requirements - it works well.

************************************************************************************************************

g_COFilter = TBL_COOBJ_900.getDataSource().getVariableValues("<<BW Variable>>")[0];

var l_txt = "";

var i = 0;

switch (g_COFilter.type) {

case VariableValueType.Single:

var singleValue = cast(Type.SingleVariableValue, g_COFilter);

console.log(singleValue.value); // can access the 'value' property now

TXT_COFILTER.applyText(singleValue.value);

break;

case VariableValueType.Multiple:

var multiValue = cast(Type.MultipleVariableValue, g_COFilter);

console.log(multiValue.values); // can access the 'values' property now

for (i = 0; i < multiValue.values.length; i++){

l_txt = l_txt + multiValue.values[i] + '\r\n';

TXT_COFILTER.applyText(l_txt);

}

break;

case VariableValueType.Range:

var rangeValue = cast(Type.RangeVariableValue, g_COFilter);

console.log(rangeValue.from); // can access the 'from' property now

console.log(rangeValue.to); // can access the 'to' property now

// further range properties: 'less', 'lessOrEqual', 'greater', 'greaterOrEqual'

TXT_COFILTER.applyText(rangeValue.from + rangeValue.to);

break;

default:

break;

}

************************************************************************************************************

Best regards

Robert

JBARLOW
Active Contributor
0 Kudos

Did anyone ever find a solution to this?