cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying Measure Totals as Dynamic Text using a Global Script

Former Member
0 Kudos

Hello,

I want to display 2 Measure Totals as Dynamic Text on a Page in Design Studio from a Data Source.

The 2 Columns are called ECOSYSTEM and OPERATIONAL_COSTS, and there are 3 rows also used in this Data Source to break down the Totals into individual groupings.

I want to know what would be the best Getmethod to use in order to display this? I have tried getTotalsDisplay and other methods without much success.

I don't actually use these particular columns in a Crosstab or a Scorecard etc., but I wanted them included in the Data Source so I could use the totals within the Design Studio application.

Ideally, I would use a Getmethod to grab the totals, and then use SetText in another Script to use those values as Dynamic Text.

Thanks,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Andrew,

Please find the script for same:

DataSourceName.getDataAsString("MeasureName", {}); - This will return "Total" value as string and you can set it directly into textbox.

Replace Data source name and Measure name to whatever is in your case and it will work.

Thanks,

Anand

chandrasekhar6
Participant
0 Kudos

Hi Anand,


Thanks Anand 

When I apply above script in Drop-down getting total value of measure display on Text box.


I have one problem when I select any dimension from Drop-down it shows only Total value,how to dynamic change values based on dimension selection from Drop down.


Please share your valuable ides...


Thanks,

Chandra

Former Member
0 Kudos

Hello Chandra,

Please filter the dimension member first and then get the total value.

Filtering Dimension Member code:

DatasourceName.setFilterExt("DimensionName", DROPDOWNNAME.getSelectedValue());

Now the data source only contains filtered member for that dimension. So, the total value will be the same as member value.

Next line, write the get totals code and it will work.

Thanks,

Anand

chandrasekhar6
Participant
0 Kudos

Hi Anand,

I am applied same as above it shows same problem.

Thanks,

Chandra

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank you, this worked for me in order to get a Measure Total.

Now another question I have related to this, is it possible to get a Dimension Result using a similar method or is it only possible for Measures?

e.g. I have different Currency Symbols in a CURRENCY_SYMBOL Column, and I want to use one of the results as Dynamic Text again.

Former Member
0 Kudos

Hello Andrew,

Could you please provide a screenshot of your edit initial view? I didnt understand your question.

It will give a better understanding and let you know if it is possible or not.

Thanks,

Anand

Former Member
0 Kudos

See the attached.

The Currency Symbol (a Dimension which is a Calculated Column) could change from a $ to different Currency, and I would like to use that as Dynamic Text, as I did with the total Measure.

Former Member
0 Kudos

Hello Andrew,

I understand that your currency symbol column values can change based on something.

But if the currency value for all members are going to change and be the same, you can use below code:

DataSourceName.getMembers("DimensionName", 0);

This will return first element of CURRENCY_SYMBOL. Since all members have same Currency, first element is enough.

For e.g.,

You have a YEAR dimension, CURRENCY_SYMBOL and measure. Assuming you have 3 rows for YEAR and all the CURRENCY_SYMBOL are same like shown below, the above code will work.

2016   $     10

2015   $     20

2014   $     30

Thanks,

Anand

Former Member
0 Kudos

I tried using that formula in a Script, and I am getting a "Cannot convert from MemberArray to String" error appearing.

I am trying to assign a Global Script Variable called Currency (which is a string) in order to then use that value in another script.

Former Member
0 Kudos

Hello Andrew,

var temp = DataSourceName.getMembers("DimensionName", 0);

Store the above value in a local variable and then write a foreach loop in next line.

temp.foreach(){

}(not exact syntax)

Inside foreach loop, please write:

GlobalVariableName = element[0];

Your global variable will now have the currency symbol.

Thanks,

Anand

MustafaBensan
Active Contributor
0 Kudos

Hi Andrew,

In this scenario, you will probably find that getMembers("DimensionName", 0) will not return the desired currency symbol.  The reason is that the values returned by getMembers() are independent of the data result set, so what will be returned is simply the first master data value of the currency symbol dimension, which will not necessarily correspond to the currency symbol in the actual data result set. 

Unfortunately, there is no equivalent of getDataAsString() for dimensions.  This is why Mike Howles has created the Design Studio 1.6 SDK Data Iterator component.  Using this component, you can simply apply the getDimensionValueKey("CURRENCY_SYMBOL") method to the first row of the result set to retrieve the currency symbol that is actually in the data set.  If you need the text, you can also apply getDimensionValueText("CURRENCY_SYMBOL").

Regards,

Mustafa.

MustafaBensan
Active Contributor
0 Kudos

Hi Andrew,

Further to my previous comment, if your data source is a Universe or if the currency dimension is being filtered, getMembers("DimensionName", 0) may in fact retrieve the desired result.  In this case, to test the assignment of the value of the currency symbol to a global script variable, instead of looping through the array, you can simply apply the following more condensed script code:

var myCurrencyDimensionMember = DS_1.getMembers("CURRENCY_SYMBOL", 0)[0];

myCurrencySymbol = myCurrencyDimensionMember.internalKey;  // Global Script Variable

If you need the currency text you can apply the following:

myCurrencySymbol = myCurrencyDimensionMember.text;  // Global Script Variable


Regards,


Mustafa.


MustafaBensan
Active Contributor
0 Kudos

Hi Andrew,

As I recall getTotalsDisplay() only returns whether totals are being displayed or not.  To get the actual totals values you should use getData().  The following blog on the subject may be helpful:

Regards,

Mustafa.