官术网_书友最值得收藏!

Parent-child relationship in a report

In the previous recipe, we created a very basic report with a list of countries. While we are in a development phase, this type of report is useful to control if the attribute forms have been created correctly. Similarly, to check the parent-child settings, you can create a quick report with two or more attributes involved in the relationships; just to be sure that every son has its father and no family is broken.

Getting ready

You need to have completed the previous recipes to continue.

How to do it...

We are now creating a report on the Time dimension:

  1. Go to My Personal Objects | My Reports, right-click on the right pane and select New | Report.
  2. Leave Blank Report selected and click on OK.
  3. In My Shortcuts pane on the left, click on Attributes, and from the list that appears on the right-click on Year.
  4. Select Add to Rows.
  5. Do the same with Month, you'll see that the two attributes appear as columns in the Report View pane.
  6. Run the report by selecting the View | Grid View menu.
  7. You can now click on Save and Close and name the report: 02 Calendar.

How it works...

MicroStrategy reads the metadata to get the information needed to produce the SQL and issues the query. The resulting dataset is then displayed and the Parent attribute rows are merged. You only see the Year values appearing once in the grid, with the corresponding Months, this is the default behavior.

There's more...

Re-run the report and look at the results, isn't it strange? Uh-Oh, year 2005 starts in July. In this particular case, we are using test data and in fact the database only holds dates starting from July 2005. However, in a real-world project, this situation should raise a flag of attention, and we'd better go to the sqlcmd console to check the DimDate table.

Now scroll to the end of the report. Year 2008 also has fewer months, year 2009 is missing, and year 2010 only has November. Definitely not a very good date dimension: can you imagine what would happen if we had sales in 2009 or 2010? Yes, probably they would disappear from the sales reports due to inner JOIN and this is one of the most common mistakes we can do in BI. Sometimes dimension tables are incomplete, long forgotten, or simply not updated; it helps to check them every now and then.

It happened to a project of mine. Back in 2009, I had a Time table with dates until year 2012: three years is a long life span for a report (I thought), so 2012 would be enough. Wrong! That report survived more than expected and in January 2013 it started returning no rows. With a red face I had to modify the Time table and, since bad habits are hard to break, I inserted dates until 2015. Guess what?

Note

You can watch a screencast of this operation at:

主站蜘蛛池模板: 深圳市| 开远市| 德保县| 陆河县| 晋州市| 洛宁县| 汽车| 武汉市| 巩留县| 安庆市| 潢川县| 元朗区| 临汾市| 嘉鱼县| 沾益县| 北票市| 漳平市| 开阳县| 萝北县| 庆云县| 镇雄县| 温宿县| 宁都县| 海丰县| 西畴县| 瑞丽市| 长武县| 朝阳区| 健康| 交城县| 玛沁县| 澄城县| 邵阳市| 辽中县| 吴旗县| 长垣县| 汤原县| 托里县| 禹州市| 新乐市| 江津市|