Skip to Content
avatar image
Former Member

SAP Design Studio Crosstab get Measure title and dimension

Hi

In my crosstab I need to filter the selected dimension text and the measure title.

So when the users clicks on the data cell, the two elements (dimension and measure) should filter what the user has selected.

If the selection type is set "Multi" and the selectable area on "multi", I can click on the dimension area or measure title and I get the names "like Light Distillates ST" or "2007". But not both.

Has anybody a solution how I can filter both (Light Distillates ST & 2007) by clicking on the data cell?

Best regards

2.png (10.1 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 10, 2016 at 10:28 AM

    Hi Roman,

    I've gone through your screenshot 12th line is showing error because you included "var dsSelection" variable declaration in 5th line comment part.

    Follow this script from 5th line to 7th line or go through by screenshor which i shared.

    var dim2Member=CROSSTAB_1.getSelectedMember("_haeI0eawEeW8WrMC3hELww").text; /*It will give selected value of dimension_2 row. */

    var dsSelection=CROSSTAB_1.getSelection(); /* Returns the selection */

    var colMember="";

    Now 12th line error will resolve.

    sap-ds-error.png

    Regards,

    Santosh Kumar

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 08, 2016 at 04:21 PM

    Hi Roman,

    For any number of dimensions in rows and columns in your crosstab by below code.

    var Dim_columns= DS_CROSSTAB.getDimensions(Axis.COLUMNS);

    var Dim_rows= DS_CROSSTAB.getDimensions(Axis.ROWS);

    Dim_rows.forEach(function(element, index)

    { DS_1.setFilter(element, CROSSTAB_1.getSelectedMembers(element)); });

    Dim_columns.forEach(function(element, index)

    { DS_1.setFilter(element, CROSSTAB_1.getSelectedMember(element)); });


    So you will get all dimension in rows and columns in two variables, then you can filter them using for loop.

    Thanks,

    Poovarasan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 09, 2016 at 09:31 AM

    Hi Poovarasan

    Thanks for your prompt reply. Unfortunately I have two dimension (isn't shown in the pic). Therefore I get the text of the second dimension. But actually I need the text of the first dimension. And the year is called measure or its technical name.

    So my settings:

    Selection type = Data cell (because I wanna click on a data cell)

    Selectable Area = All

    Here a better example of my crosstab

    Example:

    If I click on 12932 (yellow marked field), I should be able to set a filter on another crosstab / data source with the two values e.g. 2010 for the year and the name "Rob Tomson".

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 09, 2016 at 02:10 PM

    Hi Roman,

    I understood the issue as you mentioned in your example,same has been faced here once while working in my report.

    Yon can follow below steps that I followed,feel this will help:

    1. Click on "OnSelect" event of CROSSTAB_1.

    2. Put this below code:

    /*Here For CROSSTAB_1 component i've used DS_1 datasource */

    var dim1Member=CROSSTAB_1.getSelectedMember("_XzBkEPVvEeWjLIYOKteTKg").text; // It will give selected value of dimension_1 row.

    var dim2Member=CROSSTAB_1.getSelectedMember("_haeI0eawEeW8WrMC3hELww").text; //It will give selected value of dimension_2 row. var dsSelection=CROSSTAB_1.getSelection(); // Returns the selection

    var colMember="";

    /* to get column selected value*/

    dsSelection.forEach(function(value, key) {

    if(key=="_Jb4E4Oa0EeW8WrMC3hELww") {

    value.forEach(function(element, index) {

    APPLICATION.createInfoMessage("Id "+element);

    colMember=element;

    }); }

    // APPLICATION.createInfoMessage("key"+key);

    });

    /* So here you will get dimMember,dimMember1 and colMember now by using this variables you can filter datasource.*/ DS_2.setFilter("_XzBkEPVvEeWjLIYOKteTKg", dim1Member); // filter for dimension_1 row .

    DS_2.setFilter("_haeI0eawEeW8WrMC3hELww", dim2Member);// filter for dimension_2 row .

    DS_2.setFilter("_Jb4E4Oa0EeW8WrMC3hELww", colMember);// filter for column.

    3. save and run you application.

    I feel it will work in your scenario.

    Regards,

    Santosh Kumar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 09, 2016 at 03:39 PM

    Thanks a lot, unfortunately it does not work either.

    Here the issues

    What do I do wrong?

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 10, 2016 at 08:34 AM

    Hi Roman,

    If you want to filter only measure dimension and a specific dimension in rows. you can use below code.

    var measure=DS_CROSSTAB.getMeasuresDimension();

    var dim= DS_CROSSTAB.getDimensions(Axis.ROWS)[0];

    //The zero represents the position of the dimension in rows.

    DS_1.setFilter(measure, CROSSTAB_1.getSelectedMembers(measure));

    DS_1.setFilter(dim, CROSSTAB_1.getSelectedMembers(dim));

    Let me know if you need any help on this.

    Thanks,

    Poovarasan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 10, 2016 at 10:29 AM

    Hi Roman,

    I've gone through your screenshot 12th line is showing error because you included "var dsSelection" variable declaration in 5th line comment part.

    Follow this script from 5th line to 7th line or go through by screenshor which i shared.

    var dim2Member=CROSSTAB_1.getSelectedMember("_haeI0eawEeW8WrMC3hELww").text; //It will give selected value of dimension_2 row. var dsSelection=CROSSTAB_1.getSelection(); // Returns the selection

    var colMember="";

    Now 12th line error will resolve.

    sap-ds-error.png

    Regards,

    Santosh Kumar.

    Add comment
    10|10000 characters needed characters exceeded