Forum Discussion
> consolidations don't clear them the way I expected. [...] consolidation doesn't particularly care *how* the data got there
Well, that's not really the case... The Storage Type of the cells will determine what happens to the numbers when the DataUnit calculates, in combination with the "Clear Calculated Data During Calc" option on the Scenario and "If NoData" settings on the Cube. The Storage Type will depend on how the data got there.
> in some scenarios these members are populated with durable calcs
That's the problem, lol... If you tell the product "this data should never be deleted unless I very explicitly say otherwise", you'll have to be very explicit when you change your mind 😉
> if I could find the offending members by writing some kind of rule that looked at number of children and the state of the data cells.
You probably can, but getting it right will depend a lot on the precise circumstances of your data. For example, something like this (untested) script should clear all cells that are not marked as Real data in the current Data Unit:
If Not api.Entity.HasChildren
Dim filtered As New DataBuffer()
Dim dbf As DataBuffer = api.Data.GetDataBufferUsingFormula("RemoveZero(A#All)")
For Each cell As DataBufferCell In dbf.DataBufferCells.Values
If cell.CellStatus.IsRealData Then
filtered.SetCell(si, New DataBufferCell(cell), False)
Else
filtered.SetCell(si, New DataBufferCell(cell.DataBufferCellPk, Nothing, DataCEllStatus.CreateDataCellStatus(True, cell.CellStatus.Invalid)))
End If
Next
api.Data.ClearCalculatedData("A#All", True, True, True, True)
api.Data.SetDataBuffer(filtered, api.Data.GetExpressionDestinationInfo(""))
If api.Data.GetDataBufferUsingFormula("RemoveZero(A#All)").DataBufferCells.Count = 0 Then
brapi.ErrorLog.LogMessage(si, $"Delete candidate: {api.Pov.Entity.Name}")
End If
End If
This is very rough and probably excessive, but the point is to show that the CellStatus property of a cell has a few different methods to test the type of data it holds, so depending on what you're interested in clearing you can test for Real, "Real or Derived", Derived, result of a calculation, locked, etc - use Intellisense to look them up. I'd run this kind of thing in a custom calculate, targeting base members and C#Local, then Consolidate.
Once data is cleared, deletion can be automated too, but we wouldn't recommend it.