Skip to Content
0

Asking for dimension member A value and take Dimension member B value based on A. SCRIPT LOGIC

Dec 15, 2016 at 10:46 PM

41

avatar image

Hello experts,

I have a question related Scripto logic. I have been reading that to ask for a dimension member value, you need to use Ternary expression. A>B ? C : D.

Lets say I have the dimensions Category, Account, Time, Entity, Currency, Worker, Company Code and SUPNOM.

SUPNOM has let´s say 2 members:Salary and Company. Company makes reference to Company Code.

The ratio of Company its for the user to capture the company code for the worker it could change, is very changable so could not be an attribute of the dimension worker.

My question is the next.

How to check the company code based on the %value% and then take the Salary value,

i.e.

*When SUPNOM

*IS Company

*REC (EXPRESSION= %VALUE%==1000? (HERE i wanto to set the value contained in Salary, not the 1000), 0

How to take the value I want instead of the value 1000?

Thanks for the posts.

Best Regares.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Vadim Kalinin Dec 16, 2016 at 08:34 AM
1

Sample of slow script:

*XDIM_MEMBERSET COMPANY=COMP_NONE
*XDIM_MEMBERSET SUPNOM=Salary
*WHEN COMPANY
*IS *
*REC(EXPRESSION=([SUPNOM].[Company]==1000) ? %VALUE% : 0, COMPANY=1000)
*REC(EXPRESSION=([SUPNOM].[Company]==1100) ? %VALUE% : 0, COMPANY=1100)
*REC(EXPRESSION=([SUPNOM].[Company]==1200) ? %VALUE% : 0, COMPANY=1200)
... //for all possible companies
*ENDWHEN

each line will check the current record...

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Vadim,

Thank you very much for the code, one last question about the anwer. Is it possible to make it this way?

XDIM_MEMBERSET COMPANY= A
*WHEN SUPNOM 
*IS Company
*REC(EXPRESSION=(%Value%==1000) ?[SUPNOM].[Salary] : 0, COMPANY=1000)
*REC(EXPRESSION=(%Value%==1100) ?[SUPNOM].[Salary] : 0, COMPANY=1100)
*REC(EXPRESSION=(%Value%==1200) ?[SUPNOM].[Salary] : 0, COMPANY=1200)
*NEXT

I ask bc salary is just one value I need to save in the other company. The functional requirement is the next:

Payroll Budget must be in Company A and Company B, C or D, depend on the employee. The salary is not just one dimension member it is 10 to 17 members. Each employee belongs to company B, C or D, it is identified by a Value.

So I was planning on doing a for:

XDIM_MEMBERSET COMPANY= A
  *WHEN SUPNOM 

*For %BENEFIT%= B1, B2, B3..Bn
*IS Company
*REC(EXPRESSION=(%Value%==1000) ?[SUPNOM].[Salary] : 0, COMPANY=1000)
*REC(EXPRESSION=(%Value%==1100) ?[SUPNOM].[Salary] : 0, COMPANY=1100)
*REC(EXPRESSION=(%Value%==1200) ?[SUPNOM].[Salary] : 0, COMPANY=1200)
*next
0

For sure it's possible to loop on supnom is company. But at the end you will have very slow code. Just test yourself. Badi is a better solution for this requirement.

0
Vadim Kalinin Dec 16, 2016 at 08:17 AM
0

In general it's a bad idea to store member ID (company code) as a signeddata value. Script logic is badly supporting the logic required (can be done but will be very slow with a huge loop).

If you still want to use the described logic - write a custom logic badi or write back badi.

Share
10 |10000 characters needed characters left characters exceeded