 Former Member

# BPC 10 Script Logic: Using MDX Median

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]. , [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

10|10000 characters needed characters exceeded

• Posted on Feb 04, 2013 at 11:43 AM

Hi David,

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

Kind regards

Roberto

10|10000 characters needed characters exceeded
• Former Member
Posted on Feb 05, 2013 at 12:43 AM

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].,[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

10|10000 characters needed characters exceeded
• Former Member
Posted on Mar 08, 2013 at 01:13 PM

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].)

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