Cube Optimization in SSAS

In a BI solutions, SSAS cube may contains billions of records. In such large volume of data, query processing will be crucial. End user wants to get the output without much delay and to cater that you need to optimize the query processing. Otherwise it may take minutes to get the query results.

Anyway before optimizing the cube, DW must be designed properly to get the good query performance. In this post, only the cube optimization is considered.
For cube optimization, two main approaches can be used

  • Partitioning
  • Aggregation Designing


Partitioning

Since there are large volumes of data, we can split those data of a measure group, into different portions by considering different attribute values. Those portions of data set of a measure group are called as partitions.
As an example we can create partitions considering the month value. For each month there will be different partitions under one measure group. Those partitions are not visible to the end user and the user will only see one measure group.
Creating partition will help to process partitions separately and if only one partitions gets changed, then only that partition can be processed without affecting other partitions. Therefore partitioning is making the maintenance of the cube much easier.

Aggregation Designing

By using aggregation designing, Cube keeps pre-calculated set of data. It will increase the query performance, since those calculations are already done in the query execution.
We can design aggregation using the below two methods in SSAS cube.

  1. Design Aggregations Wizard 
  2. Usage Based Optimization Wizard


Both of above wizards can generated using the Aggregations tab of the Cube in BIDS.
In the Design Aggregation options, we can set the thresholds for the required aggregations and it will automatically design aggregations according to those thresholds.

Usage Based Optimization method uses the executed queries and design aggregations based on those. In that approach, aggregations are designed based on the frequently used queries, which takes more time.

For the long run, Usage Based Optimization will provide more query performance for the end user, since it will design aggregations based on the used queries.

Used the below reference to identify the steps used in BIDS for those aggregation design methods.
Design Aggregation Wizard
Usage Based Optimization Wizard





The job failed. Unable to determine if the owner (Domain\User) of job SSISJob has server access...

I created a SSIS package, which connects to the SQL Server database using windows authentication.
Package run successfully when I executed it in the BIDS and I tried to schedule a job to execute the package.

When I tried to run the job, I got the below error message.

The job failed.  Unable to determine if the owner (Domain\User) of job SSISJob has server access (reason: Could not obtain information about Windows NT group/user 'Domain\User', error code 0x5. [SQLSTATE 42000] (Error 15404))

To fix it what I had to do is set the Log On account of the SQL Server Agent to a domain account.
Normally it is set for a built in account.
Then check whether the Owner of the job is set to the same domain user as the Log On account.

This fixed my problem and I was able to run the job successfully. 

Tips to avoid empty pages and white spaces in SSRS reports...

Sometimes we find that there are white spaces or empty pages in the SSRS report viewer output or the PDF output. In this post I am going to mention the tips we can use to avoid those.
  • Set the ConsumeContainerWhitespace property of the report to True.
  • Set the body content to fit enough for the Report Page Width. Consider the margins too. Body width + Left and Right margins needs to be less than the report page width. Otherwise there will be blank spaces while exporting to PDF.
  • Remove unwanted space between the tables or charts in the report.
  • Check the page breaks, and disable those if there are no data by checking the Count of the data set.
  • Set the page breaks if you are setting the visibility of a particular section by using a parameter, by applying the same condition for the Disable property.
If those things were done properly, there will not be any unwanted white spaces or empty pages in the report.

Ordering Sub Reports dynamically in SSRS by using parameter values...

There are some requirements that the order of the tables or sub reports needs to be changed according to the provided parameter values. I tried to find a way and searched the internet. But the found solution was add sub reports multiple times and show or hide those by considering the parameter value.
But this is not a good way because if there are 10 reports (tables) to be sorted, then we have to add all those 10 reports for each position and it will load 100 reports due to that.

I was able to get done this in a different way and it will provide better performance than this.
What I did was I kept all those tables in a single report instead of separate sub reports and show or hide those table by considering the passed parameter value. In that add a parameter as "Report" to keep the which table is need to be showed. This report is used as the sub report and in the main report what I did was create a data set considering the provided ordering parameter values.
Let say we have two tables and want to sort those table according to the given position.
For the first table, position is provided by the P1 parameter and the position of the second table is provided by the P2 parameter.
Then a dataset is created using those parameter values and the query is as below.


   1: SELECT        @P1 AS Position, 'Report1' AS Report
   2: UNION
   3: SELECT        @P2 AS Position, 'Report2' AS Report



In the data set just pass those parameters as below



Then add a table and set the DataSetName as the created data set and add sub report to the detail cell as shown below.



In the table, set the Sorting property of the Details group by the Position value in the created data set.
Also in the Sub Report pass the Report value in the data set to the report as shown below.



In the sub report which contains those two tables, set the visibility of those tables by considering the "Report" parameter value.
Also to avoid loading the unwanted dataset data, we can only execute the query by checking the "Report" parameter value and if only it matches with the relevant table.
This will improve the performance since only the required data is retrieved and does not load all the data sets.

How to sub string a string value using a character value in SSRS

In a report you may want to get a part of a string value by considering a character or characters.
Such a situation we have to use Mid and InStr functions.

Assume that the Description filed value contains "/".
If we want to get the string before that "/", we can use the below expression in the report text box field.

   1: Mid(Fields!Description.Value,1,InStr(Fields!Description.Value,"/")-1)

InStr function provides at which location that the "/' character exists.
You can get the last part after the "/" character by using the below expression

   1: Mid(Fields!Description.Value,InStr(Fields!Description.Value,"/")+1,Len(Fields!Description.Value))

How to avoid data is moving to the next page in SSRS even though the space is available in the previous page...

Recently I faced an issue that in a SSRS table, data in a particular row is moving to the next page if the content with in that row is not fit enough to the available space.

We can overcome this issue by setting the KeepTogether property of the Row Cell to False.
Select the particular Row Cell and go to the Properties window. In that you can find the KeepTogether property. Default the value is set to True, change it to False.
That is it. Just run the report and you will see the content is moved to that free space and additional content is  moved to the next page.

Split first word from a field in SQL table

We can use SUBSTRING and CHARINDEX functions to split the first word from a value in SQL.
As an example, if there is a field as FullName in UserInfo table and if we want to get the first word of it, then we can use the below query to get it.

   1: SELECT  FullName , SUBSTRING( FullName ,0,CHARINDEX(' ',Name+' ',0)) AS FirstName
   2: FROM            dbo.UserInfo

In the CHARINDEX function I added ' ' to it, because otherwise it will return null if the FullName value only has a single word.

tablename_WriteToDataDestination: Mashup Exception Data Source Error Couldn't refresh the entity...

 Once a Dataflow is created and published on Fabric, got the below error while refreshing the Dataflow. tablename_ WriteToDataDestination: M...