Set of Days in past 6 equivalent MTDs - ssas
Imagine today it is the 22nd June 2010 (I've used this date as AdvWrks cube is old)
I would like to find the set of days that make up this month i.e. 1st June - 22nd June plus the days in the previous 5 equivalent months to date.
So these days would make up the set:
(1st Jan 2010 - 22nd Jan 2010) +
(1st Feb 2010 - 22nd Feb 2010) +
(1st Mar 2010 - 22nd Mar 2010) +
(1st Apr 2010 - 22nd Apr 2010) +
(1st May 2010 - 22nd May 2010) +
(1st Jun 2010 - 22nd Jun 2010)
The following gives me this set of 132 days:
WITH
SET [Days in Current Month] AS
[Date].[Calendar].[Date].&[20100601]:[Date].[Calendar].[Date].&[20100622]
SET [Mths in Past 6 Mths] AS
Tail
(
[Date].[Calendar].[Month].MEMBERS
,6
)
SET [Prev Equiv MTDs] AS
Generate
(
[Mths in Past 6 Mths]
,Head
(
Descendants
(
[Mths in Past 6 Mths].CurrentMember
,[Date].[Calendar].[Date]
,SELF
)
,[Days in Current Month].Count
)
)
SELECT
{} ON 0
,[Prev Equiv MTDs] ON 1
FROM [Adventure Works];
Is it possible to find this set of days without using the Generate function?
Here is one way:
WITH SET FirstDateOfMonth AS [Date].[Calendar].[Date].&[20100622].Parent.FirstChild
SET LastDayOfMonth AS [Date].[Calendar].[Date].&[20100622]
SELECT {} ON 0,
//CurrentMonth
{
FirstDateOfMonth.ITEM(0)
:
LastDayOfMonth.ITEM(0)
}
+
//-1 month
{
ParallelPeriod(
[Date].[Calendar].[Month],
1,
FirstDateOfMonth.ITEM(0)
)
:
ParallelPeriod(
[Date].[Calendar].[Month],
1,
LastDayOfMonth.ITEM(0)
)
}
+
//-2 month
{
ParallelPeriod(
[Date].[Calendar].[Month],
2,
FirstDateOfMonth.ITEM(0)
)
:
ParallelPeriod(
[Date].[Calendar].[Month],
2,
LastDayOfMonth.ITEM(0)
)
}
+
//-3 month
{
ParallelPeriod(
[Date].[Calendar].[Month],
3,
FirstDateOfMonth.ITEM(0)
)
:
ParallelPeriod(
[Date].[Calendar].[Month],
3,
LastDayOfMonth.ITEM(0)
)
}
+
//-4 month
{
ParallelPeriod(
[Date].[Calendar].[Month],
4,
FirstDateOfMonth.ITEM(0)
)
:
ParallelPeriod(
[Date].[Calendar].[Month],
4,
LastDayOfMonth.ITEM(0)
)
}
+
//-5 month
{
ParallelPeriod(
[Date].[Calendar].[Month],
5,
FirstDateOfMonth.ITEM(0)
)
:
ParallelPeriod(
[Date].[Calendar].[Month],
5,
LastDayOfMonth.ITEM(0)
)
}
ON 1
FROM [Adventure Works]
And here is one more:
SELECT
{
[Date].[Calendar].[Date].&[20100622].PARENT.FirstChild
:
COUSIN
(
[Date].[Calendar].[Date].&[20100622],
[Date].[Calendar].[Date].&[20100622].PARENT
)
}
+
{
[Date].[Calendar].[Date].&[20100622].PARENT.LAG(1).FirstChild
:
COUSIN
(
[Date].[Calendar].[Date].&[20100622],
[Date].[Calendar].[Date].&[20100622].PARENT.LAG(1)
)
}
+
{
[Date].[Calendar].[Date].&[20100622].PARENT.LAG(2).FirstChild
:
COUSIN
(
[Date].[Calendar].[Date].&[20100622],
[Date].[Calendar].[Date].&[20100622].PARENT.LAG(2)
)
}
+
{
[Date].[Calendar].[Date].&[20100622].PARENT.LAG(3).FirstChild
:
COUSIN
(
[Date].[Calendar].[Date].&[20100622],
[Date].[Calendar].[Date].&[20100622].PARENT.LAG(3)
)
}
+
{
[Date].[Calendar].[Date].&[20100622].PARENT.LAG(4).FirstChild
:
COUSIN
(
[Date].[Calendar].[Date].&[20100622],
[Date].[Calendar].[Date].&[20100622].PARENT.LAG(4)
)
}
+
{
[Date].[Calendar].[Date].&[20100622].PARENT.LAG(5).FirstChild
:
COUSIN
(
[Date].[Calendar].[Date].&[20100622],
[Date].[Calendar].[Date].&[20100622].PARENT.LAG(5)
)
}
ON 1,
{} ON 0
FROM [Adventure Works]
And one more...
WITH SET FirstDateOfMonth AS [Date].[Calendar].[Date].&[20100622].Parent.FirstChild
SET LastDayOfMonth AS [Date].[Calendar].[Date].&[20100622]
MEMBER Measures.PositionOfDate AS {FirstDateOfMonth.ITEM(0):LastDayOfMonth.ITEM(0)}.COUNT
SET Dates AS
HEAD(
[Date].[Calendar].[Date].&[20100622].Parent.ITEM(0).CHILDREN,
Measures.PositionOfDate
)
+
HEAD(
[Date].[Calendar].[Date].&[20100622].Parent.LAG(1).ITEM(0).CHILDREN,
Measures.PositionOfDate
)
+
HEAD(
[Date].[Calendar].[Date].&[20100622].Parent.LAG(2).ITEM(0).CHILDREN,
Measures.PositionOfDate
)
+
HEAD(
[Date].[Calendar].[Date].&[20100622].Parent.LAG(3).ITEM(0).CHILDREN,
Measures.PositionOfDate
)
+
HEAD(
[Date].[Calendar].[Date].&[20100622].Parent.LAG(4).ITEM(0).CHILDREN,
Measures.PositionOfDate
)
+
HEAD(
[Date].[Calendar].[Date].&[20100622].Parent.LAG(5).ITEM(0).CHILDREN,
Measures.PositionOfDate
)
SELECT Dates ON 0,
{} ON 1
FROM [Adventure Works]
And this way too:
WITH SET FirstDateOfSelectedMonth AS [Date].[Calendar].[Date].&[20100622].Parent.FirstChild
SET SelectedDate AS [Date].[Calendar].[Date].&[20100622]
MEMBER Measures.PositionOfDate AS {FirstDateOfSelectedMonth.ITEM(0):SelectedDate.ITEM(0)}.COUNT
SELECT
PeriodsToDate
(
[Date].[Calendar].[Month],
SelectedDate.ITEM(0).PARENT.lag(5).FirstChild.LEAD(Measures.PositionOfDate - 1)
)
+
PeriodsToDate
(
[Date].[Calendar].[Month],
SelectedDate.ITEM(0).PARENT.lag(4).FirstChild.LEAD(Measures.PositionOfDate - 1)
)
+
PeriodsToDate
(
[Date].[Calendar].[Month],
SelectedDate.ITEM(0).PARENT.lag(3).FirstChild.LEAD(Measures.PositionOfDate - 1)
)
+
PeriodsToDate
(
[Date].[Calendar].[Month],
SelectedDate.ITEM(0).PARENT.lag(2).FirstChild.LEAD(Measures.PositionOfDate - 1)
)
+
PeriodsToDate
(
[Date].[Calendar].[Month],
SelectedDate.ITEM(0).PARENT.lag(1).FirstChild.LEAD(Measures.PositionOfDate - 1)
)
+
PeriodsToDate
(
[Date].[Calendar].[Month],
SelectedDate.ITEM(0)
)
ON 1,
{} ON 0
FROM [Adventure Works]
EDIT
Slow code with non-repeating blocks:
WITH SET FirstDateOfSelectedMonth AS [Date].[Calendar].[Date].&[20100601].Parent.FirstChild
SET SelectedDate AS [Date].[Calendar].[Date].&[20100601]
MEMBER Measures.PositionOfDate AS {FirstDateOfSelectedMonth.ITEM(0):SelectedDate.ITEM(0)}.COUNT
MEMBER Measures.PositionOfCurrentDate AS
([Date].[Calendar].currentmember.Parent.FirstChild:[Date].[Calendar].currentmember).COUNT
SELECT
{
[Date].[Calendar].[Date].&[20100601].Parent.LAG(5).FirstChild.ITEM(0)
:
[Date].[Calendar].[Date].&[20100601]
}
HAVING Measures.PositionOfCurrentDate <= Measures.PositionOfDate
ON 1,
{} ON 0
FROM [Adventure Works]
Related
How to SQL conver to dataframe
I want to convert to SQL to dataframe.\ SELECT day, MAX(id), MAX(if(device = 'Mobile devices with full browsers', 'mobile', 'pc')), AVG(replace(replace(search_imprshare, '< 10%', '10'), '%', '') / 100), REPLACE(SUBSTRING(SUBSTRING_INDEX(add_trackingcode, '_', 1), CHAR_LENGTH(SUBSTRING_INDEX(add_trackingcode, '_', 1 - 1)) + 2), add_trackingcode, '') FROM MY_TEST_TABLE GROUP BY day But I can only do below that. I don't know how to work on '???'. df_data= df_data.groupby(['day').agg( { 'id': np.max, 'device ' : ???, 'percent' : ???, 'tracking' : ??? } ) How should I do it?
Edit fields of a jsonb array in postgresql
I have the following jsonb in db: [ { "state": 2, "activity": "EJECUCIÓN", "final_date": "2020-02-24", "activity_id": 1, "current_days": -7, "initial_date": "2020-02-24", }, { "state": 2, "activity": "REVISIÓN", "final_date": "2020-02-25", "activity_id": 2, "current_days": 0, "initial_date": "2020-02-25", }, { "state": 2, "activity": "RECEPCIÓN", "final_date": "2020-02-27", "activity_id": 4, "current_days": 0, "initial_date": "2020-02-27" } ] I run the following query to update the current_days field: WITH activity_state as ( SELECT taex_id,('{'||index-1||',current_days}')::text[] as pathe , ((task_activity->>'final_date')::date - current_date) as current_days, task_activity->'state' as state, task_activity->>'final_date' as final_date, task_activity->>'current_days' as curren FROM task_executions,jsonb_array_elements(taex_activitygraph) with ordinality arr(task_activity,index) WHERE task_activity->>'state' = '2' ) update task_executions SET taex_activitygraph = jsonb_set(taex_activitygraph,activity_state.pathe,to_jsonb(current_days),true) FROM activity_state WHERE task_executions.taex_id = activity_state.taex_id AND activity_state.state = '2' But that query only updates me the first element of the JSON array that exists the others do not undergo changes although in the first part of the query. ( SELECT taex_id,('{'||index-1||',current_days}')::text[] as pathe , ((task_activity->>'final_date')::date - current_date) as current_days, task_activity->'state' as state, task_activity->>'final_date' as final_date, task_activity->>'current_days' as curren FROM task_executions,jsonb_array_elements(taex_activitygraph) with ordinality arr(task_activity,index) WHERE task_activity->>'state' = '2' ) It brings me all the elements of the array that should be updated but the second part that is where it is supposed to update them: update task_executions SET taex_activitygraph = jsonb_set(taex_activitygraph,activity_state.pathe,to_jsonb(current_days),true) FROM activity_state WHERE task_executions.taex_id = activity_state.taex_id AND activity_state.state = '2' Just update me the first item.
Assuming this structure and data: postgres=# \d task_executions Table "public.task_executions" Column | Type | Collation | Nullable | Default --------------------+-------+-----------+----------+--------- task_activitygraph | jsonb | | | postgres=# SELECT jsonb_pretty(task_activitygraph) FROM task_executions ; jsonb_pretty -------------------------------------- [ + { + "state": 2, + "activity": "EJECUCIÓN", + "final_date": "2020-02-24", + "activity_id": 1, + "current_days": -7, + "initial_date": "2020-02-24"+ }, + { + "state": 2, + "activity": "REVISIÓN", + "final_date": "2020-02-25", + "activity_id": 2, + "current_days": 0, + "initial_date": "2020-02-25"+ } + ] (1 row) ... this UPDATE should work: postgres=# UPDATE task_executions SET task_activitygraph = ( SELECT jsonb_agg( CASE WHEN elem->>'state' = '2' THEN jsonb_set( elem, '{current_days}', to_jsonb((elem->>'final_date')::date - current_date) ) ELSE elem END ) FROM jsonb_array_elements(task_activitygraph) AS a(elem) ); UPDATE 1 Documentation: https://www.postgresql.org/docs/9.5/functions-json.html Side note: In transactional databases (where you have many concurrent clients, and processing speed and storage efficiency matters), and if your objects have fixed structure, DO NOT STORE your data as JSON. Use relational data model instead.
Using fb-prophet Package to Predict By Group with Additional Regressors in R
prophet users of the world, hope all is well. I'm having some difficulties with a particular use case that I'll try to illustrate using some sample data and code below. First let's generate some sample data so that it will be a little bit easier to know what I am talking about. library(data.table) library(prophet) library(dplyr) # one year of months to be used for generating predictions ds = c('2016-01-01', '2016-02-01','2016-03-01','2016-04-01','2016-05-01','2016-06-01','2016-07-01','2016-08-01','2016-09-01','2016-10-01','2016-11-01','2016-12-01' ) # historical customer counts y = c (78498,12356,93732,5556,410,10296,9779,744,16407,100484,23954,141398,10575,850,16334,17496,1643,28074,93181, 18770,129968,11590,850,16738,17510,1376,27931,94369,18444,134850,13386,919,19075,18050,1565,31296,112094,27995, 167094,13402,1422,22766,20072,2340,37863,87346,16180,119863,7691,725,16931,12163,1241,25872,87455,16322,116390, 6994,620,13524,11059,990,22188,105473,23652,154145,13520,1008,18857,19209,1632,31105,102252,21284,138779,11670, 918,16078,16679,1257,26755,115033,22415,139835,13965,936,18027,18642,1407,28622,155371,40556,174321,25119,1859, 35326,28844,2962,51582,108817,19158,109864,8693,756,14358,13390,1091,21419) # the segment channels of the customers segment_channel = c('Existing_Omni', 'Existing_Retail', 'Existing_Direct', 'NTB_Omni', 'NTB_Retail', 'NTB_Direct', 'React_Omni', 'React_Retail', 'React_Direct') # an external regressor to be added to the model (in my data there are like 40 of these regressor variables that I would like too add) flash_sale = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3) fake_data = merge(ds,segment_channel, all.y=TRUE) setnames(fake_data, 'x', 'ds') setnames(fake_data, 'y', 'segment_channel') nrow(fake_data) # should be 108 rows, the 9 customer segements for each of the months in 2016 # next join the known customer counts, let's say we have them for the first 8 months of the year fake_data = cbind(fake_data, y) fake_data = cbind(fake_data, flash_sale) # set some of the y values to NA so we can pretend we are trying to predict them using the ds time series as well as the flash sale values, # which will be known in advance fake_data = as.data.table(fake_data) fake_data$ds = as.Date(fake_data$ds) fake_data[, y := ifelse(ds >= '2016-08-01', NA, y)] This code will generate a data set fairly similar to what I am working with for my problem, so hopefully you may be able to reproduce what I am doing. There are essentially two things I would like to be able to do with this data. The first is fairly straight forward, I want to be able to obviously add a regressor (like flash_sale in this example to the prophet model that I create. I can do this fairly easily like so: christ <- tibble( holiday = 'christ', ds = as.Date(c('2016-11-01', '2017-11-01', '2018-11-01', '2019-11-01')), lower_window = 0, upper_window = 1 ) nye <- tibble( holiday = 'nye', ds = as.Date(c('2016-11-01', '2017-12-01', '2018-11-01', '2019-11-01')), lower_window = 0, upper_window = 1 ) holidays <- bind_rows(nye, christ) m <- prophet(holidays = holidays) m<- add_regressor(m, name = "flash_sale") m <- fit.prophet(m, fake_data) forecast <- predict(m, fake_data) prophet_plot_components(m, forecast) This should generate a fairly ugly plot but it's pretty easy to see that given the data this should be able to do the trick, and I could add multiple lines to add additional regressors. Ok, so we're all good so far. But the other issue is that I have 9 segment channels that I'm dealing with, and I don't want to build a separate model for each of them. Luckily I found a pretty good link on stack overflow that accomplishes the grouped prophet prediction: Using Prophet Package to Predict By Group in Dataframe in R fcst = fake_data %>% group_by(segment_channel) %>% do(predict(prophet(., seasonality.mode = 'multiplicative', holidays = holidays, seasonality.prior.scale = 10, changepoint.prior.scale = .034), make_future_dataframe(prophet(.), periods = 11, freq='month'))) %>% dplyr::select(ds, segment_channel, yhat) fcst > fcst # A tibble: 207 x 3 # Groups: segment_channel [9] ds segment_channel yhat <dttm> <fct> <dbl> 1 2016-01-01 00:00:00 Existing_Direct 38712. 2 2016-02-01 00:00:00 Existing_Direct 40321. 3 2016-03-01 00:00:00 Existing_Direct 42648. 4 2016-04-01 00:00:00 Existing_Direct 45130. 5 2016-05-01 00:00:00 Existing_Direct 46580. 6 2016-06-01 00:00:00 Existing_Direct 49437. 7 2016-07-01 00:00:00 Existing_Direct 50651. 8 2016-08-01 00:00:00 Existing_Direct 52685. 9 2016-09-01 00:00:00 Existing_Direct 54719. 10 2016-10-01 00:00:00 Existing_Direct 56687. # ... with 197 more rows This is more or less exactly what I want! Cool. So now all I have to do is figure out how to get my grouped predictions and my regressors added all in one step. I know I can have multi-line statements inside of do, so this is what I tried in order to get this to work: > fcst = fake_data %>% + group_by(segment_channel) %>% + do( + predict(prophet(., seasonality.mode = 'multiplicative', holidays = holidays, seasonality.prior.scale = 10, changepoint.prior.scale = .034), + add_regressor(prophet(., holidays = holidays), name = 'flash_sale'), + fit.prophet(prophet(. , holidays = holidays)), + make_future_dataframe(prophet(.), periods = 11, freq='month'))) %>% + dplyr::select(ds, segment_channel, yhat) Disabling yearly seasonality. Run prophet with yearly.seasonality=TRUE to override this. Disabling weekly seasonality. Run prophet with weekly.seasonality=TRUE to override this. Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this. n.changepoints greater than number of observations. Using 4 Disabling yearly seasonality. Run prophet with yearly.seasonality=TRUE to override this. Disabling weekly seasonality. Run prophet with weekly.seasonality=TRUE to override this. Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this. n.changepoints greater than number of observations. Using 4 Error in add_regressor(prophet(., holidays = holidays), name = "flash_sale") : Regressors must be added prior to model fitting. Darn. Looks like it was running but then something about how I tried to add the regressor wasn't kosher. Next I it tried this way: > fcst = fake_data %>% + group_by(segment_channel) %>% + do( + prophet(holidays = holidays), + add_regressor(prophet(., holidays = holidays), name = 'flash_sale'), + fit.prophet(prophet(. , holidays = holidays)), + predict(prophet(., seasonality.mode = 'multiplicative', holidays = holidays, seasonality.prior.scale = 10, changepoint.prior.scale = .034), + make_future_dataframe(prophet(.), periods = 11, freq='month'))) %>% + dplyr::select(ds, segment_channel, yhat) Error: Can only supply one unnamed argument, not 4 Call `rlang::last_error()` to see a backtrace > fcst = fake_data %>% + group_by(segment_channel) %>% + do( + add_regressor(prophet(., holidays = holidays), name = 'flash_sale'), + fit.prophet(prophet(. , holidays = holidays)), + predict(prophet(., seasonality.mode = 'multiplicative', holidays = holidays, seasonality.prior.scale = 10, changepoint.prior.scale = .034), + make_future_dataframe(prophet(.), periods = 11, freq='month'))) %>% + dplyr::select(ds, segment_channel, yhat) Error: Can only supply one unnamed argument, not 3 Call `rlang::last_error()` to see a backtrace I'm super confused at this point so I'm just hoping something out on the interwebs might know just the right incantation I need to get where I'm going.
How can I accurately display numpy.timedelta64?
As the following code makes apparent, the representation of numpy.datetime64 falls victim to overflow well before the objects fail to work. import numpy as np import datetime def showMeDifference( t1, t2 ): dt = t2-t1 dt64_ms = np.array( [ dt ], dtype = "timedelta64[ms]" )[0] dt64_us = np.array( [ dt ], dtype = "timedelta64[us]" )[0] dt64_ns = np.array( [ dt ], dtype = "timedelta64[ns]" )[0] assert( dt64_ms / dt64_ns == 1.0 ) assert( dt64_us / dt64_ms == 1.0 ) assert( dt64_ms / dt64_us == 1.0 ) print str( dt64_ms ) print str( dt64_us ) print str( dt64_ns ) t1 = datetime.datetime( 2014, 4, 1, 12, 0, 0 ) t2 = datetime.datetime( 2014, 4, 1, 12, 0, 1 ) showMeDifference( t1, t2 ) t1 = datetime.datetime( 2014, 4, 1, 12, 0, 0 ) t2 = datetime.datetime( 2014, 4, 1, 12, 1, 0 ) showMeDifference( t1, t2 ) t1 = datetime.datetime( 2014, 4, 1, 12, 0, 0 ) t2 = datetime.datetime( 2014, 4, 1, 13, 0, 0 ) showMeDifference( t1, t2 ) print "These are for " + np.__version__ 1000 milliseconds 1000000 microseconds 1000000000 nanoseconds 60000 milliseconds 60000000 microseconds -129542144 nanoseconds 3600000 milliseconds -694967296 microseconds 817405952 nanoseconds These are for 1.7.1 Is this just a bug in np.timedelta64? If so, what idiom / workarounds have people used when working with np.timedelta64?
Adding a Total column to MDX
I have the following query that gives me an extract (I am putting this into a CSV from my cube). I want to show the Total of all NRx in a column as the first column NRx and the rest of the NRx columns should come up as they do now. I tried to add a SUM (Measures.NRx) to this, but it did not work How do I get a Total NRx column? SELECT NON EMPTY CrossJoin ( [Time Period].[Calendar].[Cycle Dt], { [Measures].[NRx] } ) ON COLUMNS, NON EMPTY {( [Prescriber].[Prescriber Name].[Prescriber Name].Members , [Prototype Alignment].[Tier Code].[Lilly Tier Code].Members , [Prototype Alignment].[Territory Name].[Territory Name].Members , [Prototype Alignment].[District Name].[District Name].Members , [Prototype Alignment].[Division Name].[Division Name].Members , [Prototype Alignment].[Area Name].[Area Name].Members , [Market Product].[Product Group Nbr].[Product Group Nbr].Members , [Market Product].[Product G Name Name].[Product G Name Name].Members )} DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ({ [Prescriber].[Ims Prescriber Id].&[011111] } , { [Time Period].[Cycle Dt].&[2008-10-03T00:00:00], [Time Period].[Cycle Dt].&[2008-10-10T00:00:00], [Time Period].[Cycle Dt].&[2008-10-17T00:00:00], [Time Period].[Cycle Dt].&[2008-10-24T00:00:00], [Time Period].[Cycle Dt].&[2008-10-31T00:00:00], [Time Period].[Cycle Dt].&[2008-11-07T00:00:00], [Time Period].[Cycle Dt].&[2008-11-14T00:00:00], [Time Period].[Cycle Dt].&[2008-11-21T00:00:00], [Time Period].[Cycle Dt].&[2008-11-28T00:00:00], [Time Period].[Cycle Dt].&[2008-12-05T00:00:00], [Time Period].[Cycle Dt].&[2008-12-12T00:00:00], [Time Period].[Cycle Dt].&[2008-12-12T00:00:00], [Time Period].[Cycle Dt].&[2008-12-19T00:00:00], [Time Period].[Cycle Dt].&[2008-12-26T00:00:00], [Time Period].[Cycle Dt].&[2008-12-26T00:00:00] } ) ON COLUMNS FROM [Mart] ) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
What if you made a calculated member before the SELECT query with something like this: SUM ([Measures].[NRx], [Time Period].[Calendar].[Cycle Dt])? Then just do: SELECT NON EMPTY [MYCALCMEMBER_SUM] * CrossJoin([Time Period].[Calendar].[Cycle Dt], {[Measures].[NRx]}) ON COLUMNS,