Calculation Manager CDFs @CalcMgrCompare

So recently i had a requirement to do a string compare in a project, normally i would just use HspStringCompare but this time i wanted to try the new(ish) @CalcMgrCompare function.  So being that i have never used this i reverted to my favorite reference material (Google) to find some syntax. This is about where things slowed down.  The only things i could find were very basic, and with no usage examples sort of like this:

@CalcMgrCompare(text1, text2,ignoreCase)
com.hyperion.calcmgr.common.cdf.StringFunctions.compare(String,String,boolean)

And that was about as detailed as they got.

So stuck, i decided to open up a calc script and test it out.

First lets define some of the parameters:
Text 1 : This is a string value to be compared against Text 2
Text 2: This is a string value to be compared against Text 1
ignoreCase: this is a Boolean value as to weather or not case (Upper or Lower) should be considered

Text 1 and Text 2 are pretty straight forward, but what about ignoreCase, how do you pass a Boolean value into a function?  The Essbase Tech Ref and further google searching were of no help to me so i got to playing around.  My script would validate and act as expected if i used 1==1 or 1==2 for True and False, but 1 or 0 would not work.  After a bit of searching I eventually found (by using insert function in calculation manager) that it is looking for @_true or @_false as parameters.


So from here a couple tests and results, and this is what i got:

Examples:
@CalcMgrCompare("ABC","ABC",@_true) will return True since both values are equal
@CalcMgrCompare("ABC","abc",@_true) will return True since case is ignored
@CalcMgrCompare("ABC","ABC",@_false) will return True since both values are equal
@CalcMgrCompare("ABC","abc",@_false) will return False since both not equal and case is considered
@CalcMgrCompare("ABC","ABCD",@_true) will return False since both are not equal

For your string values you can use any function that returns a string, for example when comparing an RTP against a member name you could use @NAME({RTP_Member}) and @Name(Member) since @Name returns a string value.

Hope this makes your searching a little quicker, and good luck on your project, what ever it may be.

Comments

  1. Hi,

    I wound up not needing and using MbrCompare, but I did test it. It worked, and your blog saved me so much time and grief. Thank you!

    ReplyDelete
  2. Very Awesome , it's helped a lot thanks a lot

    ReplyDelete

Post a Comment