Showing posts with label filter. Show all posts
Showing posts with label filter. Show all posts

Saturday, 3 November 2012

MDX Functions


Once you know basics we can have look at the basic functions and properties of MDX.
I hope you have read the previous blog MDX  Introduction.  

In the last post I have shown you a very basic MDX, it just show one member, if you want to see all the members than

SELECT {[Measures].[Internet Sales Amount]} ON COLUMNS,
[Date].[Calendar Year].ALLMEMBERS on 1
FROM [Adventure Works]

Using . ALLMEMBERS to a dimension attribute will give you all the members of that attributes.

Just like this we have some more properties and function

PREVMEMBER
 Gives you previous member of a Dimension Member.  

SELECT {[Measures].[Internet Sales Amount]} ON COLUMNS,
[Date].[Calendar Year].&[2009].PREVMEMBER on 1
FROM [Adventure Works]

So you will get data across Year 2008.

RANGE
Range is not a function but it’s a way of writing MDX, by which you can see data for a range of dimension member.  
SELECT {[Measures].[Internet Order Count]} on 0,
{[Date].[Calendar Year].&[2005]:[Date].[Calendar Year].&[2007]} on 1
FROM [Adventure Works]

FILTER
If you want to filter data on Axis based on a condtion you can use filter function.  Like following
SELECT [Measures].[Internet Sales Amount] ON 0,
FILTER
(
[Date].[Date].[Date].MEMBERS
, [Measures].[Internet Sales Amount]<10000 o:p="o:p">
) ON 1
FROM [Adventure Works]

FILTER takes a set and a condition as input parameter.
In above example we are showing all the dates for which we have Internet sales amount more than 10000.
Instead of a measure you can also have Dimensions as Filter condition.

EXCEPT
Same as FILTER there is Except
--Except

SELECT [Measures].[Order Quantity]
   ON COLUMNS,
   Except
      ([Product].[Product Categories].[All].Children ,
         {[Product].[Product Categories].[Components]}
      ) ON ROWS
FROM
   [Adventure Works]

It gives you result except the condition, so its other way around of Filter.
So it takes a set and a condition as input parameter, but here result will exclude the condition and gives you result.
This are few function I have explained you above, in next post will see more of those. 

Sunday, 31 May 2009

Use of Date Range in PPS Reports

Its very common scenario when customers ask us to develop a report based on a particular date range.
Like list of students join between 12th January 2009 and 2nd February 2009.

These kind of reports are easy to make using SQL Server Reporting Services.
But what if we want to use Microsoft Performance Point.

Following are the screen shot and steps require building a report using a date range.

1. Creating a simple report (in screen shot I am taking [Time].[Year - Half Year - Quarter - Month - Date].[Date] on the Y-axis so that we can see that filters are working properly.)





2. On the Query tab adding two parameter Range1 and Range2




3. Editing MDX as shown in Screenshot



Changing the [Time].[Fiscal Day].Allmembers to [Time].[Fiscal Day].[Fiscal Day] so that we don’t have column named “all” in the report.
Inserting where clause -
WHERE {<> :<>}

4. setting default values for the parameter Range1 and Range2



Here I am giving [Time].[Date].&[2008-05-21T00:00:00] as default value for one of the parameter.
The reason of taking different attributes in parameter and on Y-axis is that for same attribute it won’t work.

5. Now on the Design tab we can see that it is showing only those columns which comes under Date Range.

sss

6. Now creating two filters named From and To in dashboard, Filters are member selection filter based on [Time].[Date]




7. Linking the reports to the filter. Remember that’s Dashboard item end point for from is Range1 and for To is Range2. Source value should be Member Unique Name.




8. Publish dashboard and Preview.




In preview we can see that it is showing data between a date ranges.


But taking Tree or Drop down Box is not useful as its not have ease of use.
We can even use calendar instead of it.



For using calendar in filters. We have to use Time Intelligence Post Formula Filter.

For using any Time intelligence filter you have to configure the time settings of data source.
Go to data Source --> Time Tab ... See the screen shot.






Configure it in a way it is showing in Screen shot.

(For more information on configuring time Intelligence Filters Please refer http://office.microsoft.com/en-us/help/HA102408431033.aspx )


After configuring data source. We create two Time intelligence Filter From and To.
Then link the filter as per the screen shot



After that click on the Filter Link Formula…



And insert Formula by typing “Day“.

Formula “Day” means we want day level data. Other options like Month, Quarter can be used.

After it publish and Preview it.




In the Screen shot you can see that how can a calendar control works.






Thanks,
Gaurav Gupta