Good DayI am quite a newbie to MDX and feeling my way through. I have created an SSAS Cube sourced off a SQL DW and have a requirement to report one specific metric - staffinservice.Each Month, new staff join the company and I need to report figures for monthly, quarter, year and so on.My ScenarioMonth New Staff Total StaffOct 1 15Nov 2 17Dec 0 17Q4 17YTD 17This is sort of a to date metric. The data I am sourcing off rolls up the monthly values just fine. The problem I have is that when it gets to any time period above month, instead of returning the todate figures, it is rolling up all the monthly totals (which is actually by design) and reporting 15+17+17 = 49 for Q4. The same applies for anything above the month. If I pulled up YTD staff count, as supposed to reporting 17, it's adding up all total staff values from Jan to current month.Any helping on the MDX syntax to create this calculated member is appreciated. The TSQL Definition of what I am looking is below and result sets attached[code="sql"]IF OBJECT_ID ('tempdb..#tmpLIS') > 0 DROP TABLE #tmpLISSELECT d.yearno, d.quarterno, d.monthno, s.segment_nm, SUM(f.Staffin)endStaff, SUM(BeginningStaff)BeginningStaffINTO #tmpLISFROM FactVES f inner join DimDate d on d.MMYYYY = f.MonthYrKey inner join DimSegment s on s.Segment_ID = f.SegmentIDwhere d.YearNo = 2014 and s.Segment_NM = 'Marketing'group by d.yearno, d.quarterno, d.monthno, s.segment_nmorder by d.QuarterNoSELECT quarterno, MAX(BeginningStaff)BeginningStaff, MAX(endStaff)endStafffrom #tmplisgroup by quarternoorder by quarternoSELECT Yearno, MAX(BeginningStaff)BeginningStaff, MAX(endStaff)endStafffrom #tmplisgroup by Yearnoorder by Yearno[/code]Thank you.
↧