You are on page 1of 9

DIMENSION WRITEBACK and CELL WRITEBACK in Analysis Services (Writing Back to the Cube) Part 1 MSBI Cube pulls

s data from relational database on the basis of defined processing strategy (Process full, Process Incremental) and storage options (MOLAP, ROLAP and HOLAP). In few situations, we would like to write back directly to cube. This can be achieved by Writeback Functionality in SSAS. In SSAS, you can directly write data to cube dimension and measures which will be reflected in relation data source as well. There are two types of Writeback in SSAS.

1. Dimension Writeback 2. Cell Writeback


When dimension data is updated then it is called Dimension Writeback and when measure/ fact data is updated, it is called Cell Writeback. Situations where Writeback will be useful?

1.

2.

(Dimension Writeback): For example, In Product dimension case: you want to add new product then it can be added by using Writeback feature or you are going to start new campaign in coming Christmas or want to promotional cost related to existing campaign. Writeback feature is good only for small number of updates because for each DML operation one request will be sent to relational database. It is better to change relation DB and then reprocess cube data. Writeback feature provides great flexibility to users who dont have direct access to relation DB. (Cell Writeback): Tuples value can be changed while viewing result set. Most prevailing example is budget or forecasting data. By cell Writeback, change budget or forecasting data and see effect on different matrices to analyze business. You can option to commit the change data or rollback it in cube.

Dimension Writeback Dimension can be changed in SQL Server management studio as well as in business intelligence development studio. Dimension Writeback has some limitations: 1. 2. 3. Dimension table should be from single table. Snowflake dimension are not supported. Named query and DB Views are not supported. In Cube Dimension, Dimension key and name columns properties should be same.

for using in the post , I am creating DimProduct_Writeback table by the help of Adventure Works DW table Dim Product. I can not directly Dim Product because of mentioned limitations.

view plainprint?

1. 2. 3. 4. 5.

CREATE TABLE [dbo].[DimProduct_Writeback]( [ProductKey] [int] NOT NULL, [Color] [nvarchar](15) COLLATE Latin1_General_CS_AS NOT NULL, [Size] [nvarchar](50) COLLATE Latin1_General_CS_AS NULL, [SizeRange] [nvarchar](50) COLLATE Latin1_General_CS_AS NULL

6.

view plainprint?

1. Insert into [dbo].[DimProduct_Writeback]


2. 3.

4.
5.

6.
7.

8.
9.

10.

([ProductKey], [Color], [Size] , [SizeRange]) select [ProductKey], [Color], [Size] , [SizeRange] from [dbo].[DimProduct]

Dimension Writeback cannot write back to identity column so I have created PRODUCTKEY[dbo]. [DimProduct_Writeback] table into regular integer column. Lets create dimension using [FactInternetSales] table will be used as Measure Group.

Cube Snapshot How will you enable Writeback and How will you write back to cube as well as to relation database? In Dimension Properties, set WriteEnabled property to True.

Once you make "WriteEnabled" Property to TRUE then in browser tab, Writeback icon will be enabled.

Now Dimension can be updated in Dimension Browser tab or by using SQL Server Management Studio Dimension Browser tab. In this post, We will use BIDS Dimension Browser tab. Now take key attribute in Hierarchy Menu (Dim Product Writeback key attribute in example) and click on Member properties and then on Show All):

Result will show all attributes related to key attribute:

Now we are ready to Writeback in Cube as well as in relation database. Lets click on Writeback icon in menu bar near Member Properties and right click on any row in data:

1. CREATE SIBLING: Now We can insert record in dimension. In the example, New product can
be inserted by this option.

2. CREATE CHILD: For my example, this option is disabled but if you use Parent Child
Relationship in your dimension then this will be enabled to insert new child for the parent.

3. DELETE: Record can be deleted from dimension as well as underlying relation table. 4. UPDATE: You can directly modify value of any cell by just selecting the cell and entering new
data.

Example of New row insertion:

It will create new row in the dimension as well as in the [DimProduct_Writeback] table.

Lets understand how events have happened at server level: 1. 2. 3. MDX INSERT/DELETE/Update statement to analysis server in form to XMLA SQL DML Statement to relational DB Processing Dimension and incremental Cube Processing

MDX INSERT/DELETE/Update statement to analysis server in form to XMLA

SQL DML Statement to relational DB It sends DML operation to relational database in parametrized query: view plainprint?

1. INSERT INTO [dbo].[DimProduct_Writeback] 2. ([ProductKey],[Color],[Size],[SizeRange]) 3. VALUES (?,?,?,?)


Processing Dimension and incremental Cube Processing Once data has been written back to relational table and cube dimension then it process cube to bring in consistent form and reflects changed data. These events can be observed by SQL Server profiler.

DIMENSION WRITEBACK and CELL WRITEBACK in Analysis Services (Writing Back to the Cube) Part 2

As I explained in my last post, when you write back to measures then it is called Cell Writeback. Like Dimension Writeback, there are limitations with Cell Writeback also. For enabling Cell Writeback, all measures should have aggregation as SUM in measure group. If measure group contains other aggregations like count, distinct count, max etc. then move them to separate measure group. Cell Writeback is not possible using graphical user interface like we have for dimension Writeback using SQL Server Management Studio (SSMS) or Business intelligence studio (BIDS). It can only be done by writing MDX queries through SSMS. However you can built your own front end application and pass right XMLA script to analysis server. Lets understand how can we implement cell Writeback? There are two major steps: 1. 2. Enable Cell Writeback for measure group/partition Execute MDX queries for changing cell/tuple values for same measure group/partition

1. Enable Cell Writeback for measure group/partition Go to cube Partition tab, right click on measure group partition and select Writeback Settings.

It will open new pop up window, where your changes will be recorded. By default, table name will be WriteTable_. You can change table name and data source if you want to record in some other table or data source.

Once you click "OK", it will create one extra partition (Writeback Partition) for recording changes. Once you deploy solution, same SQL Server table will be created in Specified data source.

So now Cell Writeback has been enabled. Now lets change some data in cube. 2. Execute MDX queries for changing cell/tuple values values for same measure group/partition MSDN Document provides syntax definition for updating cube data. In example, we have data from 2001 to 2004 in our cube: view plainprint?

1. select [Dim Product Writeback].[Dim Product Writeback].MEMBERS on 1 2. ,[Order Date].[Calendar Year].members on 0 3. from [Adventure Writeback Cube] 4. where ([Measures].[Sales Amount])

If business user has to enter data for 2005 then it can be done by writing UPDATE CUBE statement in SSMS: view plainprint?

1. Update [Adventure Writeback Cube] 2. set ([Order Date].[Hierarchy].[Calendar Year].&[2005]


3. ,[Measures].[Sales Amount]) = 10,000,000

One more important aspect, whenever user execute UPDATE statement server internally start new session for user with New BEGIN TRANSACTION. These changes will be visible to same user. Only when user COMMIT TRANSACTION by executing COMMIT Statement, it will be visible to others. User can ROLLBACK transactions using ROLLBACK.

You might also like