Saturday, September 22, 2012

We could query BISM Tabular model using either MDX or DAX. People are very familiar with how to use MDX in SSRS. Using DAX in SSRS is totally different from using MDX. Here is an example to create SSRS report using DAX language:

List of Steps:

1. Open SQL Server Data Tools to create a SSRS report.

2. Add an existed BISM Tabular Model as the Shared data source.

3. Write the DAX in the SSMS or DAX Studio first. The DAX Studio is an Excel Add-Ins that you could download from the CodePlex.

EVALUATE

SUMMARIZE

(

CALCULATETABLE( 'Internet Sales'

,'Product Category'[Product Category Name] = "Bikes"

) ,

'Date'[Calendar Year],

'Product Category'[Product Category Name],

"Total Sales", 'Internet Sales'[Internet Total Sales],

"Total Tax Amount", 'Internet Sales'[Internet Total Tax Amt],

"Total Margin", 'Internet Sales'[Internet Total Margin]

)

4. Create SSRS dataset

Add a new dataset and connect to the BISM Tabular Model

Open Query Designer

Click on the Command Type DMX button on the toolbar to switch to the DMX query designer.

Click on the Query/Design Mode button to switch to the Query mode.

Paste or type your DAX query into the Query window and then click on OK button.

Click on the Fields tab to fix/rename the field name to make it more readable. The field name generated by the query designer will not lineup with the column name you have in the DAX query.

Now, you could add those fields to the report.

5. Add parameter

Go to dataset query, open the query designer.

Change the DAX query by replacing the filer part of Query with parameter name and click on the Parameter Button to open the Query Parameters window

Add Parameter and set the default value, then click OK to exit out the designer

On the report data window, you will find a parameter been created with default value that you typed in.

6. Create parameter dataset

There is no parameter query generated by the tool. You need to create it if you allow user to pick from the drop down list.

Write a DAX query with VALUES() function using the same steps before to create a dataset that will contain the list of parameter values.

Report Parameter Allows Multiple Values

If you allow multiple values for the report parameter, you could not use filter with equal sign (“ = ”) in the DAX query. You could use PATHCONTAINS() function in the filter part of query to filter the result set.

PATHCONTAINS(<path>, <item>)

Since the multi select parameter string pass in will contain extra special characters that could not be used for the Path() function, you need to use Substitute() function to replace them.

Here is the complete DAX query for the report.

EVALUATE

SUMMARIZE(

CALCULATETABLE( 'Internet Sales'

,PATHCONTAINS(

substitute(

substitute(

substitute(

@CategoryName

, "{ ", "")

, " }", "")

, ",", "|")

,'Product Category'[Product Category Name] )

),

'Date'[Calendar Year],

'Product Category'[Product Category Name],

"Total Sales", 'Internet Sales'[Internet Total Sales],

"Total Tax Amount", 'Internet Sales'[Internet Total Tax Amt],

"Total Margin", 'Internet Sales'[Internet Total Margin]

)

After you update your query, the SSRS report will work for multiple selections from the user now.

Monday, September 3, 2012

Recently I created several SSIS packages with DQS component to do data cleansing jobs while loading data into data warehouse. After deploying the project to the remote server, the packages failed to execute at remote server with following exception thrown:

After research and investigation for several days, I figured out that the SQL server version on my PC is different from the remote sever which has SQL 2012 CU2. I then upgraded my client machine to SQL 2012 CU2.

After that, some DQS packages will run inside the VSDT, some will still fail with the same exception as the diagram showed:

This is caused by the length of Data Quality Project Name that DQS created, which is limited to 128 characters (a combination of the package name + DQS Cleansing component name + datetime stamp + a few GUIDs). The long project name will fail to be inserted into [DQS_MAIN].[dbo].[A_KNOWLEDGEBASE_ACTIVITY].[KNOWLEDGEBASE_NAME].

In addition, I noticed that before CU2, the project name only append one GUID at end which allows longer SSIS package name without failing. So, if you have experience of the DQS package failing to execute after upgrading to CU2, you may have the same problem.

Solution:

Right click the DQS Cleansing Component to open the component property page.

Rename the PackageName + Name of the component to be less than 30 characters.

P.S. Change the Name of the package property or SSIS package name will not change the PackageName property inside the DQS Cleansing component.

Now, the SSIS Package is able to run without exception on either client or remote server.

If you encountered the following error when you open the DQS client application, it is related to the server been upgraded without updating the DQS databases. You could run DQS installer with upgrade option in Command Prompt to resolve the issue.

DQSInstaller.exe -upgrade

Special thanks to Jason H. from Microsoft for looking into my question posted on DQS Forums.

About Me

I am a Business Intelligence IT professional and currently work for Duke Energy. I enjoy working in BI. This blog was created as a way for me to share some of the challenges and ideas that I have experienced.