Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

How to get only Last year sales for completed months

$
0
0
Hi,

I have this mdx query below which gives me the Last year sales and the way it calculates is if the user date is in the current month then give me the sales for only until that date of the month and all the sales for previous months.But, it also gives me for next month which i dont want to see but we have it in the cube since its last year it shows up.Is there anyway i can limit up the LY sales for only until the given day?

I dont want to change my rows as thats my requiement.So,  is there anyway i can alter the member LY sales?

WITH
    
member [LY Sales]             as
Iif(
       StrToMember("[Date].[Hierarchy - Fiscal].[Date].&[20131204]").Parent.Parent.membervalue = [Date].[Hierarchy - Fiscal].CurrentMember.MemberValue,
       sum(
              StrToMember("[Date].[Hierarchy - Fiscal].[Date].&[20131204]").Parent.Parent.FirstChild.FirstChild
              :
              StrToMember("[Date].[Hierarchy - Fiscal].[Date].&[20131204]"),
             SUM(([Fiscal Date Calculations].[Date Calculation].&[LY Day] , [Date].[Hierarchy - Fiscal].CurrentMember), [Measures].[EXT NET DOLLARS - Base Measure])
       ),
       Iif(
              CDate([Date].[Hierarchy - Fiscal].CurrentMember.MemberValue) <= CDate(StrToMember("[Date].[Hierarchy - Fiscal].[Date].&[20131204]").MemberValue),
              SUM(([Fiscal Date Calculations].[Date Calculation].&[LY Day] , [Date].[Hierarchy - Fiscal].CurrentMember), [Measures].[EXT NET DOLLARS - Base Measure]),
              0      
       )
)


                                                
SELECT
{
[LY Sales]
} ON COLUMNS ,
NON EMPTY
(

{[Date].[Fiscal Year].&[Year 2013]},
{[Date].[Fiscal Half].&[2013]&[1],[Date].[Fiscal Half].&[2013]&[2]},
{[Date].[Fiscal Quarter].&[2013]&[1],[Date].[Fiscal Quarter].&[2013]&[2],
[Date].[Fiscal Quarter].&[2013]&[3],[Date].[Fiscal Quarter].&[2013]&[4]},
{[Date].[Fiscal Month].&[2013]&[1],[Date].[Fiscal Month].&[2013]&[2],[Date].[Fiscal Month].&[2013]&[3],
[Date].[Fiscal Month].&[2013]&[4],[Date].[Fiscal Month].&[2013]&[5],[Date].[Fiscal Month].&[2013]&[6],
[Date].[Fiscal Month].&[2013]&[7],[Date].[Fiscal Month].&[2013]&[8],[Date].[Fiscal Month].&[2013]&[9],
[Date].[Fiscal Month].&[2013]&[10],[Date].[Fiscal Month].&[2013]&[11],[Date].[Fiscal Month].&[2013]&[12]}
)
ON ROWS
FROM EDW


Can someone please give me any ideas?

Thanks

Viewing all articles
Browse latest Browse all 14337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>