Skip to Content
avatar image
Former Member

How to get dimension members for displaying them in a text element in Design Studio?

Hello,

In DS 1.2 we are using a BW query for TOP 10 countries in a datasource as shown in the following example:

Country Turnover DE 50000 AT 40000 CN 20000 ... ..... BR 100

Country is a characteristic in rows (technical name 0COUNTRY), turnover a keyfigure in columns (technical name ZTURN) and TOP 10 is a condition in the query.

Now we want to get e. g. the second dimension member (in the example "AT") and display it in a text element (the selection of the country should be dynamic). Does anyone have ideas how we can realize this?

Thanks in advance,

Bernd

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    Aug 04, 2015 at 03:27 PM

    I had a similar scenario using 1.5

    I had a query bringing some default selection for user executing the app. I wanted to put them on global variables:

    I solved this way:

    var v_DEFAULTVALUEFORATTR1 = '';

    var v_array_DEFAULTVALUESFORATTR1 = DS_USERDEFAULTS.getMembers("ATTR1", 1);

    v_array__DEFAULTVALUESFORATTR1L.forEach(function(element, index) {

    v_DEFAULTVALUEFORATTR1 = element.externalKey;

    });

    GlobalvariabledefaultvalueforATTR1 = v_DEFAULTVALUEFORATTR1.

    This works because it only brings one line as a result, if it brought several we should go some way around.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 12, 2014 at 05:50 PM

    Hi Bernd,

    I can think of a round-about way to achieve this...Just see if it works,

    1. Populate the DS results (Country) in a listbox. (Using Set Items),
    2. I expect that the countries will appear sorted (based on Turnover) in List box as the query condition is active. (if not keep the DS sorted descending by Turnover)
    3. The first item of the listbox is default selection, you can read this using List Box (Get Selection) function
    4. This was you can find the first country and put the text and Key in any text box (if required)
    5. If you would like to get the second entry, repeat the above steps after filtering the data source with value 'not equal' to first country you already have.
    6. The steps need to be repeated for finding records lower in order.

    I expect, this will work.

    Regards,


    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Anil,

      I am just facing an issue while drag a dimension in initial view of design studio. All dimension which i put in rows are coming in either ascending or descending order. even for month it is displaying in ascending order so in chart I am not able to show values from january to december.

      How to get month dimension in order from jan to dec instead of ascending.

      Regards!

      Mathivanan.M

  • avatar image
    Former Member
    Feb 13, 2014 at 01:11 PM

    Hi Bernd,

    some food for thought:

    Option 1: do it with plain javascript (jQuery) instead of the Design Studio Scripting API

    Option 2:

    • You need to create 1-2 additional measures in your Query with replacement path for country to contain the country "id/key" and/or "name/text".
    • You would create an additional data source in Design Studio containing also the additional measures (bex formulas using replacement path).
    • Now you can (probably) use the scripting API to achieve what you want.

    (it might work, but I haven't tested it fully, I just tested separate parts of it...)

    Option 2.b) is shorter and easier to understand and maintain if you create 2 additional BEx Formulas in your Query, but not fully tested, but hope it helps.


    Option 2.a): When you create only 1 additional Key Figure/Measure/Formula in your BEx Query it would contain/display the KEY of the corresponding country value:

    (this code should only help to understand the logic applied, it is not a 100% copy/paste solution)

    /* TO GET 1st COUNTRY TEXT */

    // get measure value for first element; "COUNTRY_AS_MEASURE_UID" is the new bex formula with replacement path where the id of the country is stored; {} means empty selection means 1st value

    var measure_value_hlp = DS_HLP.getDataAsStringExt("COUNTRY_AS_MEASURE_UID", {}));

    // filter the helper datasource to contain only 1 value

    DS_HLP.setFilterExt("COUNTRY_DIMENSION", measure_value_hlp);

    // set items for listbox/dropdown in order to get the dimension value from the dropdown

    DROPDOWN_HLP.setItems(DS_1.getMemberList("COUNTRY_DIMENSION", MemberPresentation.EXTERNAL_KEY, MemberDisplay.TEXT, 1));

    // get text for first country

    var first_country = DROPDOWN_HLP.getSelectedText();

    // set text for first country

    TEXT_COUNTRY_1.setText(first_country);

    /* TO GET 2nd COUNTRY TEXT */

    // clear previous filter

    DS_HLP.clearFilter("COUNTRY_DIMENSION");

    // make a filter selection which excludes only the first item so that after the filter the first item is actually the 2nd item

    DS_HLP.setFilterExt("COUNTRY_DIMENSION", "!"+measure_value_hlp);

    // save the country id stored in the bex measure

    measure_value_hlp = DS_HLP.getDataAsStringExt("COUNTRY_AS_MEASURE_UID", {}));

    // filter the helper datasource to contain only 1 value

    DS_HLP.setFilterExt("COUNTRY_DIMENSION", measure_value_hlp);

    // set items for listbox/dropdown in order to get the dimension value from the dropdown

    // THIS DOESN'T WORK: getMemberList(...) ignores that we have already filtered the datasource to contain a different value, the same problem is here: http://scn.sap.com/message/14679358#14679358

    DROPDOWN_HLP.setItems(DS_1.getMemberList("COUNTRY_DIMENSION", MemberPresentation.EXTERNAL_KEY, MemberDisplay.TEXT, 1));

    // get text for 2nd country

    var second_country = DROPDOWN_HLP.getSelectedText();

    // set text for 2nd country

    TEXT_COUNTRY_2.setText(second_country);

    Option 2.b): When you would have 2 additional Key Figures/Measures/Formulas with replacement path in your Query: 1 would contain the country id/key and 1 would contain the NAME/VALUE of the corresponding country:

    // get the values for the 1st element

    var country_1_key = DS_HLP.getDataAsStringExt("BEX_MEASURE_REPLACEMENT_PATH_COUNTRY_KEY", {}));

    var country_1_text = DS_HLP.getDataAsStringExt("BEX_MEASURE_REPLACEMENT_PATH_COUNTRY_TEXT", {}));

    TEXT_COUNTRY_1.setText(country_1_text);

    // filter datasource: exclude the 1st element this way the 2nd element becomes the first element

    DS_HLP.setFilterExt("COUNTRY_DIMENSION", "!"+country_1_key); // "!" is used to exclude a value

    // get the values for the 1st element

    var country_2_key = DS_HLP.getDataAsStringExt("BEX_MEASURE_REPLACEMENT_PATH_COUNTRY_KEY", {}));

    var country_2_text = DS_HLP.getDataAsStringExt("BEX_MEASURE_REPLACEMENT_PATH_COUNTRY_TEXT", {}));

    TEXT_COUNTRY_2.setText(country_2_text);

    Regards,

    David

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Bernd,

      Solving this with JavaScript would mean to use the SDK to create a custom component or maybe use the component (Design Studio 1.2 SDK - Rapid Prototyping Addon HTML/JS Templating) created by @Michael Howles where you could add your JavaScript code.

      It would be a nice and helpful feature in some scenarios if Design Studio itself would contain the option to just link/add 1 custom javascript file into a bi app without a 3rd party extension, the same way as it allows to link a custom css file to your bi app via the properties setting of the application.

      I wanted to create a simple example for you using the SDK, but unfortunately I don't have the time right now (and haven't done anything with the SDK so far, but the JavaScript part of it would be quite easy - in general you just get the inner html of the item you need and set it as the html of a text component, you just need to use the correct css selectors..., but the advantage of the SDK could be that you could create/add a custom scripting method which you could then use directly in Design Studio scripting and thus you would become more flexible/reusable. One example would be to create a new method like: .copyTextFromTo("css_selector_from", "css_selector_to"); or you/somebody could create a method like: .getTextFrom("css_selector"); - this would return the innerHtml from the item targeted though a css selector and you could then set this String as the new Text for your Textbox: TEXT_X.setText(var_new_text); ).

      Regarding your question of creating key figures/formulas in the bex query which would contain either the id or text of your country dimension via a replacement path or customer exit variable I would suggest you to ask this question in the BEx space: SAP Business Explorer (SAP BEx), whether it is possible. Maybe you will be able to get only the key and not the text of your country, because key figures can/must contain a numeric value? But you can investigate this idea with some BEx Query Designer experts.

      Regards,

      David

  • Feb 13, 2014 at 04:38 PM

    Hi Bernd,

    not sure if that is really possible to get it up and running with pure BW or Design Studio (without SDK).

    But I want to bring up a new possible idea to solve it. Without having tried it.

    BW comes with analysis_process_designer

    analysis_process_designer

    analysis_process_designer

    analysis_process_designer

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 26, 2015 at 10:41 AM

    Hi,

    I have a table (A) and I select a state from the State column of A.

    Now I would like the see my selection in una text component (TEXT).

    I write this in the On Select box of A:

    var state=A.getSelectedMember("dimension state");

    TEXT.setText(state.text);

    I can trasform member to text with "dimension.text".

    Replace the "dimension state" with your dimension code.

    Best regards,

    Giulia Sogaro

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 27, 2015 at 11:20 AM

    Hi Bernd,

    this is quite old thread - have you solved your issue in the meantime (and have you upgraded DS to newer version?). If you on 1.4, you could solve it with free SDK components - SCN Design Studio SDK Development Community, component: collection utility.

    Karol

    Add comment
    10|10000 characters needed characters exceeded