cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to convert numbers to dimension member info in sac using scripting?

xyz31
Explorer
0 Kudos
498

Hello,

I have manually inputed "202309" in my input field and I have a dropdown with numbers 1 to 6 in it. The initial requirement was to add the dropdown numbers to the input field value. Lets say if I choose 2 in dropdown the input field will show 202311 as a result. I used the below code and it worked fine.

var before_LC=ConvertUtils.stringToNumber(InputField_9.getValue())+ConvertUtils.stringToNumber(Dropdown_2.getSelectedKey());
ScriptVariable_1 = before_LC.toString();

 

Now the requirment is that I need that input field to read that value (202311) as a date dimension ID so that later I can have a date dimension member description for the value (which would be Nov 2023).

Do we have any script for that?

Any support would be appreciated.

 

Thanks

 

Accepted Solutions (0)

Answers (1)

Answers (1)

N1kh1l
Active Contributor

@xyz31 

The easiest way I can think of achieving this will be using the getmember() of the Datasource. If you have a table or a chart, you can just use the datasource of it to get the description of the member and then combine it with Year from Scriptvariable 1. I am assuming you have already done the required manipulation and your ScriptVariable1 is assigned "202311"

You can use something like below

ScriptVariable_1="202411"; // Assuming this is assigned by previous logic

var DS= Table_2.getDataSource();

var Year =ScriptVariable_1.substr(0,4);  
	
ScriptVariable_2=Year+ " " +DS.getMember("Date",ScriptVariable_1).description;

 

Output: I have assigned the ScriptVariable2 to dynamic Text Box which initially shows No value but on click of the button which has the above script

N1kh1l_0-1729113364704.png

 

N1kh1l_2-1729113447341.png

 

Hope this helps !!

Nikhil

 

 

xyz31
Explorer
0 Kudos

Hi @N1kh1l,

I really appreciate your answer but I think I missed on some further details.

The value "202411" is actually saved in an another input field bcz I needed a condition to be fulfilled while using the dropdown so actually "202411" would be a derivation. 

xyz31_0-1729157568368.png
                                                       xyz31_1-1729157598667.png

Here I am getting "202403" and its desc "Mar 24" from the below code: (OnInitialization)
var z=Table_6.getDataSource().getMembers ("Start_Date",{accessMode:MemberAccessMode.BookedValues});
InputField_9.setValue(z[i].id);
InputField_10.setValue(z[i].description);

I want the second value to work the same way i.e. 202404 as Apr 24.
But here I am using a different code on the first dropdown OnClick to get my requirement fulfilled which is as below:

xyz31_2-1729157836947.png

I moulded your given code according to the need and used it on OnIntialization in order to get "Apr 24" in the second box while opening the story page. But seems like the code is not working fine. Below is the code used:

xyz31_3-1729158138017.png

Seems that there is no error in the script but it is not working.

Your help would be appreciated.

Thanks so much