on 2020 Sep 22 8:12 AM
Hello everyone, I am very new to SAP Analytical Cloud and need some assistance
I have a public dimension based on customers, to this, I have added the description and several properties address, phone number etc
I have then created a model that contains this dimension along with other dimensions
I wish to use the model in an Analytical Application, this I have also done applying filters etc, what I am unable to do is read the properties via a script of the customer dimension so that I can display them in a text box, it does not sound that difficult to achieve any suggestions appreciated
Thank you
Brian
Request clarification before answering.
Hi Brian,
do you want to know what properties are available (like does the customer has an attribute address?) or do you want to know the value of the property (like what is the address of the customer?)
Best regards
Viet
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I usually implement a hidden chart into my Analytic Application and add the respective dimension. The following example script gets the description for a dimension value (dimension name is MENU_KEY). Use the developer tools of Chrome to see what console.log() prints out. In the script editor of SAC, I often use CTRL+SPACE for code completion if I don't know what kind of arguments a method expects. And the API Reference is also a good place to search for answers: https://help.sap.com/doc/958d4c11261f42e992e8d01a4c0dde25/release/en-US/index.html
For starters, this blog is also good: https://www.sapanalytics.cloud/introduction-to-scripting-in-analytics-designer/
Hi Viet, thanks for your help it does return what I require
I do have 2 more questions however
Firstly in your example, you use selection[5], I have tried but I can't work out how to replace the 5 with a variable of the desired customer?
I currently have
var custsel = InputField_1.getValue();
console.log(Chart_5.getDataSource().getResultMember("Customer.PostalCode",{"Customer":selection[5].Customer}).description);
This gets the required customer number but I need the position in the array
Also, and I have not really looked at this yet, but when I use getDataSelections() it only returns 500 entries to the array?
Thanks
Brian
Hi Brian,
glad that I could be of help.
In order to find the right entry, I often loop through the array with a for-loop. Something like the following might work for you (I assume that custsel contains the customer you search for). Since I have used only low-volume datasets so far I was not aware that getDataSelections() might have a limit. In such cases, I assume that we need to filter the data source of our dummy chart first before we use getDataSelection().
for (var i = 0; i < selection.length; i++) {
if (selection[i].Customer === custsel) {
console.log(Chart_5.getDataSource().getResultMember("Customer.PostalCode",{"Customer":selection[i].Customer}).description);
}
}
User | Count |
---|---|
52 | |
6 | |
6 | |
6 | |
5 | |
5 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.