sql - MDX Calculation in SSAS for Sum of Sales from Start date till today -


i trying write query in ssas calculations tab should produce below result. ytd calculation calculating 1st feb 2016 till today. have written below query in management studio need convert ssas calculations , write calculations tab.

with    member [measures].[ytd sales target 2]      sum     (         strtomember         (           '[sales date].[date].&[' + format(now(),'yyyy-') + '02-01t00:00:00]'         )       :          strtomember         (               '[sales date].[date].&[' + format(now(),'yyyy-') + format(now(),'mm-')             +                format               (                 now()                ,'dd'               )           + 't00:00:00]'         )      ,[measures].[sales target]     )  select    [measures].[ytd sales target 2] on 0 [sales]; 

it should simple as:

create member currentcube.[measures].[ytd sales target 2] sum     (         strtomember         (           '[sales date].[date].&[' + format(now(),'yyyy') + '-02-01t00:00:00]'         )       :          strtomember         (               '[sales date].[date].&[' + format(now(),'yyyy-mm-dd')+'t00:00:00]'         )      ,[measures].[sales target]     ), visible = 1;   

this way won't take date account. little change can "time aware". added little check dates before 1st feb ignored.

create member currentcube.[measures].[ytd sales target 2] iif(     [sales date].[date].currentmember.member_key < strtomember('[sales date].[date].&[' + format(now(),'yyyy') + '-02-01t00:00:00]').member_key     ,null     ,sum (         strtomember         (           '[sales date].[date].&[' + format(now(),'yyyy') + '-02-01t00:00:00]'         )       :          strtomember         (               [sales date].[date].currentmember         )      ,[measures].[sales target]     )  ), visible = 1;   

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -