cancel
Showing results for 
Search instead for 
Did you mean: 

counting the number of rows in the crosstab

Former Member
0 Kudos

hi,

I am new to SAP design studio.I have a requirement where ,I have a crosstab which changes the data dynamically based on the selection in the dropdown.

I tried to achieve this using scripting.I used assign data source method to dynamically change the crosstab contents,after that i used some script like

DS_6.getMembers("[Measures]", 100);

In place of measures,the filed name should be dynamic.

Is there any inbuilt function to count the number of rows of a crosstab.If there is any ,please do let me know.

Thanks,

Deepa

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

To change the crosstab contents based on your selection you can use

Datasource.setFilter(Dimension, Value);

In order to know the number of rows  Right click on the datasource->Edit Initial View-> Right click on any one of the measure ( eg Measure1) Display result As ->Total Number of Detailed Values

Now use the following script o get the number of rows

Datasource.GetdatAsString(Measure1,{ }); This script will return the result row of Measure1 which is your count.

Hope this helps

- Karthik S

Former Member
0 Kudos

hi Karthik,

Thanks for your reply.But I am not getting "Display result As ->Total Number of Detailed Values" option.If I right click on any measure I am getting only 3 options(decimal places,scaling factor and sort).It will be helpful,if you can send a snapshot.

Thanks,

Deepa

Former Member
0 Kudos

I have used a Keyfigure and not a formula or selection. Will have to check for other cases as well.. You can also try to achieve the same in BEx Query Calculate result as Count and use the same logic.

Thanks

Former Member
0 Kudos

thanks for your reply.I have used hana at the backend(not the BEX query).If hana is the backend,then for measures it will show only 3 options in design studio 1.5.

Thanks

Former Member
0 Kudos

Ok I was not aware of that you are using HANA datasource.. Now Just a thought.. You can try some logic like this-

var a= DS.getMembers("Dimension",maximumNumber);

var count=0;

a.forEachFunction((element,index)

{

if(DS.getdataAsString("Measure",{Dimension :element.internalKey} )!="")

{

count=count+1;

}

);

former_member359113
Discoverer
0 Kudos

I found this as a nice option to count the number of records in a datasource:

var getarray = DS_1.getMembers("DataSource", 10000);

var membercount = getarray.length;

// "10000" to set a max

//To display the value in text object

//convert to string using +""

var membercountstring = membercount+"";

TEXT_1.setText(membercountstring);

Karol-K
Advisor
Advisor
0 Kudos

Hi,

small add - yes, this will work, but...

* the call itself can be quite expensive if you really have many members

* the number you get is dependent on your query setting, either "booked" values are counted or "masterdata" values are counted.

Karol

0 Kudos

Hi Karol

           I am also facing the same problem, is it because of hana back-end source that Calculate Totals as option is not available. i want max value from the list of members . do you have any other alternative thoughts in achieving this criteria

Thanks

Naveen