Effortlessly Check Member Level 0 with Groovy's Dynamic Capabilities
Shehzad Kazmi
Digital Transformation Specialist | EPM Solutions Advisor | Budgeting & Planning | Profitability and Costing | Helping businesses to realize value from their EPM investments
Groovy made easy: Check Member Level 0 in a snap
Here’s a quick short post on how you can check if a Member is Level 0
/*RTPS: {Periods}*/
Closure isLev0 = {Cube cube, Dimension dim, String member ->
(dim.getEvaluatedMembers("@RELATIVE(\"${member}\", 0)", cube).findAll({it -> it.Name != member}).size() == 0) ? true : false
}
println("Is ${rtps.Periods.member} Level 0: ${isLev0(operation.application.getCube("OEP_FS"), rtps.Periods.member.dimension, rtps.Periods.member.name)}")
I’m using an RTP but you can use this to check any member name as long as you have a reference to the cube, the dimension, and the member name.
Using the dimension object, we invoke a call to getEvaluatedMembers, which returns a List of Member objects.
I’m using this function to get all Level 0 descendants of the member name we are searching for using the @RELATIVE command.
I’m using the findAll on the returned list to return all Member objects that match the member name I am searching for, and simply checking the size of the returned List to see if it is ‘true’ or ‘false’.
Log messages :
Is YearTotal Level 0: false?
Log messages :
Is Dec Level 0: true?
A quick and simple way to check if a member is Level 0 using Groovy. Using the dimension object’s getEvaluatedMembers method and using the returned List to evaluate.
I used this for validating the prompts in case a Level 0 member is expected.