Level 0 DESCENDANTS Of @Sibling function in Groovy – Quick Tip # 8 1

If you have not read the post on @UDA function in Groovy and @ATTRIBUTE function in Groovy, please do that now 🙂

This post, we are going to look at how to get all the level 0 members of all sibling members of a user prompt.

If you look at the screenshot below and if the user selects East as the Market RTP value, then the script must provide California, Oregon,…Iowa, and Colorado.

Groovy code for @RELATIVE(@SIBLINGS(mbrName), 0)

The below-given code passes the member name to the function, which retrieves the siblings of that specific member and then finds out the level 0 members of each sibling.

/*RTPS: {Market} {Product}*/
def app=operation.application
def cube=app.getCube("Basic")
Boolean includeShared = false
def marketDim=app.getDimension("Market", cube)
def usrMarketMbrs = marketDim.getEvaluatedMembers("""Siblings(${rtps.Market.toString()})""" as String, cube)
List<Member> usrMarketDescMbrs = new ArrayList<Member>()
// loop trhough sibling members and find descenadants
	usrMarketDescMbrs.addAll(marketDim.getEvaluatedMembers("""ILvl0Descendants(${it.name})""" as String, cube).collect{it})
println usrMarketDescMbrs.collect{fixValues(it)}.join(', ')

Line 8, we are finding out all the siblings of Market (East in this case), once we get the sibling information, loop through them and find out the level 0 descendants (lines 11-13).


There, we got all the required members for @RELATIVE(@SIBLINGS(“East”),0)

If you need the members under East, change line 8 in the above-given function to the following.

def usrMarketMbrs = marketDim.getEvaluatedMembers("""ISiblings(${rtps.Market.toString()})""" as String, cube)

Leave a comment

Your email address will not be published. Required fields are marked *

One thought on “Level 0 DESCENDANTS Of @Sibling function in Groovy – Quick Tip # 8

  • Patrick

    This is a neat way to do it in Groovy! Just an extra tidbit, you can do this natively in BSO calcs as well.

    Appreciate your blog and everything you do!