Skip to Content
Former Member

# Math power function in script logic

Hello all!

Can anybody help me how I can do math "power" function in BPC 5.1 Script Logic?

Thanks

##### Add a comment
10|10000 characters needed characters exceeded

### 1 Answer

• Former Member
Posted on Nov 13, 2008 at 02:01 AM

Let's say you have a source account FOO and you want to calculate FOO to the 5th power, posting the result to FOOFIVE.

In BPC SQL scripting, there are no mathematical functions to play with (powers, roots, sine, cosine, etc.) except for add, subtract, multiply and divide -- plus you can round results in your Factor or Expression. So that means, we must use multiplication.

You could certainly do this using a bunch of intermediate accounts, one each for foo squared, foo cubed, foo to the 4th, and foo to the 5th. That would require *GO in between each *WHEN/REC block, and could be slow.

I haven't tried this, but I think this should work, all in one statement:

*XDIM_ACCOUNT = FOO

*WHEN *

*IS *

REC(Factor=GET(Account="FOO")GET(Account="FOO")GET(Account="FOO")GET(Account="FOO")*GET(Account="FOO"),Account=FOOFIVE)

*ENDWHEN

If you want FOO to the 50th power, copy & paste.

If you want square root of FOO, that could be a real challenge. I think to use straight BPC SQL logic it wouldn't be possible. I would probably write a stored procedure using SQL's SQRT(), and call that from the BPC logic file. Likewise for any other geometric functions, complex algebra, etc.

There also may be a way to calculate powers in MDX -- that's more mathematically straightforward -- but as a BPC on MS person, I really never ever use MDX due to performance.

Regards,

Tim

##### Add a comment
10|10000 characters needed characters exceeded

### Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.