ParallelPeriod() function is very useful when we need to present data side-by-side for two parallel periods
ParallelPeriod() function is often used when we need to present data side-by-side for two parallel periods, such as in the example below where daily data needs to be presented side-by-side for each day in October and November.
ParallelPeriod() is unaware which month is longer
If you have used the ParallelPeriod() function for this purpose you will surely appreciate its power. You will also experience some serious frustration too. Because ParallelPeriod() is unaware which month is longer, and it’s extremely frustrating to try to line up the days for the days when there is no data. Ideally, the query needs to be dynamic and be aware which month is longer.
Query to determine how many days in each month
So the first thing I’ll need to do is to query the cube to determine how many days in each month (days that have data).
This query is very similar to the query in MDX #20 – Last Data Date, with the Existing key word.
Without the Existing keyword, it will actually give me the number of days in the entire Date dimension. The Existing keyword forces the calculated member to be in the context of the query, which is for the month of July 2004 only.
Since I do not care each day in the month, the COUNT() function allows me to just see the number of days in the month.
If you need to query both months of July 2004 and August 2004, wrap both members up in { } (so they will be a set), and place it in the WHERE clause.