Welcome to this tutorial. In this tutorial, we will build an MDX dataset base on the public dataset
KYLIN_SALES, showing how to create and use datasets for analysis in Excel. Chapter Quick Navigation:
- What you will know
- Create MDX Dataset
- Fill in the basic information
- Define Relationships
- Modify dimension name and measure name
- Modify dimension table attributes and dimension attributes
- Create Hierarchies
- Create Calculated Measures
- Define Translation
- Edit Dimension Usage
- Edit Visibility Restrict
- Save and Create
- Analysis in Excel
- Source Code
In this tutorial you will learn about the following:
- How to create MDX datasets in
MDX for Kylin.
- How to create hierarchies and commonly used calculated measures (eg YTD, QTD, MTD, YOY and MOM) in
MDX for Kylin’s dataset.
- How to modify dimension table attributes, dimension attributes, measure attributes, and dimension usage in
MDX for Kylin’s dataset.
- How to analysis in Excel.
More details about usage of MDX for Kylin, please access to Manual of MDX for Kylin.
To complete all the lessons in this tutorial, you will need to prepare the following:
- This tutorial mainly uses Docker of MDX for Kylin as a demonstration.
- Complete the installation of Docker of MDX for Kylin, as described in Quickly try MDX for Kylin.
Kylin Salescube which status must be ready in Kylin.
Create Models/Cubes in Kylin
The current docker environment starts with the
learn_kylinproject by default, and generates
At this point, we have completed the preparation work, and then we should start creating MDX dataset.
Since the Cube in Kylin is created in the project
learn_kylin, the project name in MDX for Kylin should be
Open the Dataset menu and click the + Create Dataset button.
Click to start creating a dataset.
Fill in the dataset Name with *Kylin_Sales_Analysis*.
Click Next button when done.
This analysis will simply analyze whether there is a relationship between the data about
kylin_sales_cube to the right pane. Click the Next button when done.
To increase readability, we can change the names of dimensions and measures.
- Click on the Dimension Name on the left side of the Define Semantics page to display the dimension details.
On the Display Dimension Details page, click the Edit button to go to the edit page to change dimension name from YEAR_BEG_DT to YEAR.
- On the same way, we could change the dimension name by the following table:
|Cube Name||Table Name||Original Name||Changed Name|
Similarly, click on the measure name on the left side of the definition semantics page to display the metric details.
- On the Display Metrics Details page, click the Edit button to go to the Edit page to change dimension name from GMV_SUM to Total_Sales_Amount.
- On the same way, we could change the measure name according to the table below:
|Cube Name||Original Name||Changed Name|
In order to calculate time intelligence functions such as YTD, MTD, and QTD, it is necessary to adjust the attributes of the related dimension tables and dimensions. We need to change the dimension table property to a time type, and the dimension attributes of year, season and month to year, season and month respectively.
Modify dimension table properties
Click on the Dimension Table Name on the left side of the Define Semantic page to display the dimension table details.
Show Dimension Table Propertiespage, click the Edit button to go to the edit page, where the dimension table properties are changed from regular to time.
Modify dimension attributes
According to the method described above, you can change the properties of the edit dimension property page. Here you need to change the properties of the dimension year, quarter and month to year, season and month, and week.
For time dimensions, such as the year, month, day, and other dimensions with hierarchical structure, we generally establish a hierarchy for analysis.
If you need to use time intelligence functions such as YTD, QTD, MTD, WTD, there are the following precautions:
- Calendar hierarchy must be established.
- The attributes of the dimensions in the hierarchy are specified as year, season, month, week, and day respectively.
- When using time intelligence functions in Excel, you need to drag the hierarchy into rows or columns.
Click the Add Hierrachy button to add a hierarchy. Here, due to the needs of the analysis, create a hierarchiy called the calendar with dimensions of year, quarter, month, and date.
Dimensions in the hierarchy need to be selected in order of concept, for example, year, month, week, and then day.
Add a calculated measure by clicking the Add Calculated Measure button.
The table below lists common expressions, which you could refer to in your projects.
|Calculated Measures||Format String||MDX Expression|
In MDX for Kylin, you can embed multiple translation of a caption to provide culture-specific strings based on the localed identifier (LCID).
This feature helps international teams to consume the same dataset without the need to repeatedly defining the dataset for localization purposes.
- There are three language supported: Chinese, English(US), and English(UK).
- The objects that can be set are names of the dimension table, dimension, measure, calculated measure, and hierarchy. If a dimension is defined with a translation, then it will also be applied in the hierarchy containing the dimension.
- If the language in the analysis application client is not defined in the dataset translation, the dataset will use the default language. When using Excel, Excel will pass the LCID as language settings in Excel. For Tableau users, the language settings of the Windows system will be applied, so you can change the translations of the dataset displayed in Tableau by changing the language setting of the Windows system.
- When creating a new calculated measure, please reference the measure in the original name, instead of the translation in the MDX expression.
When editing a dataset, go to translation, click the globe icon to add a language.
Choose a language in the new column and click confirm.
In this new group of translation, the user can input the translation of table names, dimensions or measures.
The above translation defines the Chinese-English translation of the year and month.
Since Kylin does not support complex many-to-many relationships, so there is no special definition here.
Now that you have completed the main work of creating a data set in this tutorial, click the OK button.
We have completed the definition of the data set, and now we can connect to Excel for analysis.
Select Data —> From Analysis Services
Next you need to fill in the address information of MDX for Kylin in the Server Name column. The sample is as follows:
The default port of MDX for Kylin is 7080.
The username and password are your MDX for Kylin’s login username and password.
Now the Dataset is connected to Excel. Select the previously created dataset *Kylin_Sales_Analysis* and click Next.
Check Always attempt to use this file to refresh the data and click Finish.
Now you can analyze MDX for Kylin’s dataset using the Excel PivotTable.
Please access to https://github.com/Kyligence/mdx-kylin to get source code.