cancel
Showing results for 
Search instead for 
Did you mean: 

BPC 10 Script Logic: Using MDX Median

Former Member
0 Kudos

Hello!

First, sorry if I posted in the wrong place, because it is my first post. This is a question about the BPC Script Logic 10.

I'm having trouble making a "script logic" in BPC 10 which calculates the median (not average) read where all values ​​in that dimension "TYPE" is equal to 1 and record this result in the "TYPE" = 111.

Below a piece of the script, in which the problem occurs:

* When TYPE

* IS 1

* Rec (Expression = Median ([TYPE]. [1], [Measures]. [SignedData]); TYPE = 111) / / ERROR OCCURS HERE

* ENDWhen

* Commit

That is, if you had the following information lines

Line 1: 5

Line 2: 15

Line 3: 22

I want him to severe 15 (median) for each item, playing in TYPE 111.

I think the problem is because Median is an MDX and do not know to use it in code.

Could anyone help me?

Thank you

David

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

I am using the code:

[TIPO].[#111]=MEDIAN({FILTER([REVENDA].[R].Children, ([REVENDA].CurrentMember.Properties("AS")=%AS% or [REVENDA].CurrentMember.Properties("AS")='N') and ([REVENDA].CurrentMember.Properties("TERCEIRO")=%TERCEIRO% or [REVENDA].CurrentMember.Properties("TERCEIRO")='N'))},[TIPO].[11])

It was working, but now is giving error in executing the mdx

Former Member
0 Kudos

I tried the code below. Shows no error, but the calculation is not done correctly.

I'm trying to use AVG initially to facilitate the calculation is being done correctly.

*XDIM_MEMBERSET CAT_APURACAO = 1

*XDIM_MEMBERSET PERIODO_APURACAO = 2

*XDIM_MEMBERSET TIME = NONE

*XDIM_MEMBERSET TIPO = 11

        

[TIPO].[#11]=AVG({[TIPO].[111],[REVENDA].AllMembers})                //here the code           

   

*COMMIT

In case you have 4 members in the dimension [REVENDA]. Each member has the following values ​​in the dimension [TIPO] = 111:

First: 6515295

Second: 4633418

Third: 5666779

Bedroom: 3103285

The average was 4,979,694 and 5,150,098 median. That is, the calculation using AVG, he should write to each [REVENDA] the value 4979694. However, it is writing 28861790 in 4 members. Someone could tell what is wrong??

Note: AVG used to facilitate the conference, what I really need is the median.

Thank you

former_member186498
Active Contributor
0 Kudos

Hi David,

try please

* Rec (Expression = Median ([TYPE]. [1], [Measures]. [SignedData]); TYPE = "111")

Kind regards

     Roberto

Former Member
0 Kudos

It did not work, the error showed that "Median" is unknown.

It seems to me that the * rec does not accept MDX.

Is there a way to include a line without using * rec?

former_member186498
Active Contributor
Former Member
0 Kudos

Hello Roberto!

Thanks for the help!

Unfortunately I am not able to develop Script Logic.

Guess I'll have to resort to a BADI ...

I'll try to search a little more to see if I can ....

former_member186498
Active Contributor
0 Kudos

Hi David,

if you use BPC for MS you cannot use BADI ...

Kind regards

     Roberto