The Essbase 11.1 release brought us
the ability to do partial data clears within an ASO database. Gone are
the days of using report scripts or the Excel Add-In to clear data. There
a couple of posts out there on other sites about how to use MaxL and MDX to do
a partial data clear, but most of them speak to the simple clear script,
performing a restriction using one dimension. What happens when you need
to define your data clear a little more precisely?
Let's start with the basics of data
clears in an ASO Essbase cube. There are two types of data clears you can
perform, a logical delete and a physical delete. A physical delete
removes the input cells in the specified region, whereas a logical delete creates
a new slice with an exact offset of the input cells you are trying clear.
When you retrieve the data both slices are netted together and you get
zeros. The technical reference notes that a physical delete completes in
a time proportional to the size of input data while the logical completes in a
time proportional with the size of data being cleared. For this reason, a
physical data clear is suggested when removing large slices of data. It
is also warned that a logical delete will increase the size of your database.
Both of these should be taken into consideration when doing a partial
data clear.
Now on to the fun stuff…
The MaxL Script Editor can be used
to perform the clear. The syntax to be used is:
alter database
. clear data in region '{MDX set expression}' [physical]
Your appname and database name
should be placed in single quotes. The MDX set expression is the definition
of the data you want to clear. Physical is an optional keyword that
should be used when performing a physical clear. The most difficult part
of this syntax is the MDX set expression.
First and foremost, a set must have curly
brackets around it. Second, it has to be one of the prescribed MDX
functions that return a set. Remembering those two things, building the
MDX set expressions becomes easier.
Using the ASOSamp application here
are a few examples progressively showing you how you can restrict your script
more and more precisely:
- If you wanted to remove all Qtr4 data (regardless of
year or any other dimension) your command would look like this:
alter
database 'ASOsamp'.'Sample' clear data in region '{[Qtr4]}' Physical
·
If you wanted to remove
only Qtr4 for current year (regardless of any other dimension) your command would
look like this:
alter
database 'ASOsamp'.'Sample' clear data in region 'Crossjoin({[Qtr4]},{[Curr
Year]})' Physical
·
If you wanted to remove
Qtr3 and Qtr4 for current year (regardless of any other dimension) your command
could look like any of these:
o
alter database
'ASOsamp'.'Sample' clear data in region 'Crossjoin({[Qtr3]:[Qtr4]},{[Curr
Year]})' Physical
o
alter database
'ASOsamp'.'Sample' clear data in region 'Crossjoin({[2nd Half].Children},{[Curr
Year]})' Physical
o
alter database
'ASOsamp'.'Sample' clear data in region
'Crossjoin({MemberRange([Qtr3],[Qtr4])},{[Curr Year]})' Physical
·
If you wanted to remove
Qtr3 and Qtr4 units for current year (regardless of any other dimension) your
command could look like this:
alter
database 'ASOsamp'.'Sample' clear data in region
'Crossjoin(Crossjoin({[Qtr4]},{[Curr Year]}),{[Units]})' Physical
·
If you wanted to remove
Qtr3 and Qtr4 units for current year (regardless of any other dimension) your
command could look like this:
alter
database 'ASOsamp'.'Sample' clear data in region
'Crossjoin(Crossjoin(Crossjoin({[Qtr4]},{[Curr Year]}),{[Units]}),{Descendants([Online])})'
Physical
Keeping in mind the basics of MDX
scripts is the key to getting your clear script defined down to a more granular
level. It is also important to note that
the more complex your MDX is the longer your clear script may take to run. If the data set being cleared is going to be
very small you may want to use a logical delete as the increase to your
database size will not be as noticeable.
If you are going to delete a large chunk of data, the physical delete
may make more sense as a new large slice may take up a lot of memory and impact
performance.