SSRS :MDX Query to get a particular Granularity of Timeperiod (Dynamic MDX in SSRS )
Case Study : When a user want to select the Particular Granularity of time in his report when the data is coming from SSAS Cube .
Granularity :
Q – Quaterly ( for every 15 mins data)
H – Hourly
D – Daily
W – Weekly
M – Monthly
Y – Yearly
Solution :
Step 1
Create a Parameter Called Granularity and give the Values as shown below .
Step 2 : In Main Data Set
Create a parameterized named set called Peroid as shown below
with set Period as
CASE @Granularity WHEN "H" THEN {[Date].[Year - Month - Date].[Date].members *[Time].[Time Hierarchy].[Hour].members}
WHEN "D" THEN {[Date].[Year - Month - Date].[Date].members}
WHEN "M" THEN {[Date].[Year - Month - Date].[Month].MEMBERS}
WHEN "Y" THEN {[Date].[Year - Month - Date].[Year].members}
ELSE {[Date].[Year - Month - Date].[Month].MEMBERS}
END
Step 3 : Create a Named Member called Period 1 to use the Caption name on the Report
With MEMBER MyPeriod1 as iif([Time].[Time Hierarchy].CurrentMember is [Time].[Time Hierarchy].[All],[Date].[Year - Month - Date].currentmember.member_caption,[Time].[Time Hierarchy].CurrentMember.member_caption)
Step 4 : Use This Period1,Period2 members in Chart Category Groups .
The Final MDX Query Looks Like
Comments
Post a Comment