After Sign Flipping ,Data Getting Cleared When Running consolidation

Kashinath
New Contributor II

Guys, There is a requirement to reverse the signage of all Revenue Accounts, So we have a Code that gets all The Revenue Accounts and Multiplied it with ' -1' , And the data is getting Flipped . But when we try to Consolidate that flipped Data , It is getting Cleared . Also When We try to run The rule 2 or 3 times , then also the Data is Getting Cleared. Any idea why this is happening. 

This is the code that does the flipping :

Dim accountDimName As String = "Financial_Statements"
									
Dim mFilter As String = "A#[4.00.000.000].Base" 
Dim lstAccounts As List(Of MemberInfo) = BRApi.Finance.Metadata.GetMembersUsingFilter(si, accountDimName, mFilter, False)

'filter on revenue accounts
									
Dim lstRevenueAccounts As List(Of MemberInfo) = lstAccounts.Where(Function(x) BRApi.Finance.Account.GetAccountType(si, x.Member.MemberId).Equals(AccountType.Revenue)).ToList()
For Each MemberInfo As MemberInfo In lstRevenueAccounts
										
   Dim nMemberId As Integer = BRApi.Finance.Members.GetMemberId(si, Dimtype.Account.Id, 
   MemberInfo.Member.Name)
										
   Dim sValue As String = api.Members.GetMemberName( Dimtype.Account.Id, nMemberId)
										
																				 
   api.Data.Calculate("A#"& sValue &"=A#"& sValue &" * -1")
									
Next

 Thanks a lot .

2 REPLIES 2

JackLacava
Moderator
Moderator

Base data should not be altered once it's imported, for various reasons - one of them being what you're seeing here: accidentally turning real numbers into Calculated data means that they will get wiped with each calculation.

Sign-flipping can be easily achieved with Aggregation Weight in Relationship Properties, between a given child and a given parent. Set that value to -1 and let the engine do the rest.

If you really want to do it in Rules, you should brush up on the consolidation sequence and understand how you target specific Consolidation members, so that you don't wipe Local values.

chul
Contributor III

Hi Kashinath,

I wouldn't recommend the approach that you've taken given the information you've provided. Your rule is more complex than necessary. The code also contains a few items that we recommend doing your best to avoid when writing a rule: not constraining the code to base entities and C#Local, looping through a list, using BRapi instead of the available api and writing an api.data.calculate statement inside of the loop.

An easier way to accomplish the display of signage in reports and cube views is to use a dynamic UD8 member that will display the book signage based on the account type. There is an example of this below - it's far better than doubling up your revenue (and possibly liability/equity) data in the database.

To address the issue of clearing of data, it's a property on the Scenario, Clear Calculated Data During Calc, which is recommended to be set to TRUE in most cases. It sounds as though there may be an issue with where this rule is triggered during your process.

 

'This UD member is for reporting purposes.
'It flips the sign back to natural sign based on the account type

Dim acct As String = api.Pov.Account.Name
Dim acctTypeName As String = api.Account.GetAccountType(api.Pov.Account.MemberId).Name

If (Not acct Is Nothing) Then
   If acctTypeName.XFEqualsIgnoreCase("Liability") Or _
          acctTypeName.XFEqualsIgnoreCase("Revenue") Then
      Return api.Data.GetDataCell("A#" + acct + ":U8#None * -1")
   Else
      Return api.Data.GetDataCell("A#" + acct + ":U8#None")
   End If
End If

Return Nothing

 

 
cds