my previous question for SSAS MDX Previous Year - Ignore Filter was solved. Now i have an other problem. I get now the right previous year result for the store but the aggregation on country level is wrong.
My problem was i doesn't get the previous year value for a store because the filter kicked that value:
Store | Turnover Actual | Turnover PrevYear
Hamburg | 100.00 | 120.00
Munich | 140.00 | 130.00
Cologne | 90.00 | 110.00
Berlin | 150.00 | null
I tried then this query from MoazRub:
with
member [Measures].[Turnover PrevYear] as
IIF( IsEmpty([Measures].[Turnover Actual] ),
NULL,
SUM(
([Store Status].[Store Status Type].defaultmember, ParallelPeriod( [Date].[Year - Quarter - Month - Date].[Year],1,[Date].[Year - Quarter - Month - Date].CurrentMember))
, [Measures].[Turnover Actual]
)
)
Select
non empty{[Measures].[Turnover Actual],[Measures].[Turnover PrevYear]}
on Columns,
non empty{[Store].[Store].[Store].members}
on Rows
from [Sales Cube]
where (
[Date].[Year - Quarter - Month - Date].[Month].&[2020]&[1],
[Store Status].[Store Status Type].&[Comparable],
[Store].[Country].[Country].&[GERMANY]
)
I get the right result on the Store-Level:
Store | Turnover Actual | Turnover PrevYear
Hamburg | 100.00 | 120.00
Munich | 140.00 | 130.00
Cologne | 90.00 | 110.00
Berlin | 150.00 | 120.00
On the Country-Level I get a wrong SUM because now a other store "Bremen" which is "Not comparable" at january, 2020 is in the sum included.
TOTAL should be (without Bremen which one is "Not comparable": 460.00
TOTAL "is situation" : 580.00 (includes Bremen)
Query on Country-Level:
with
member [Measures].[Turnover PrevYear] as
IIF( IsEmpty([Measures].[Turnover Actual] ),
NULL,
SUM(
([Store Status].[Store Status Type].defaultmember, ParallelPeriod( [Date].[Year - Quarter - Month - Date].[Year],1,[Date].[Year - Quarter - Month - Date].CurrentMember))
, [Measures].[Turnover Actual]
)
)
Select
non empty{[Measures].[Turnover Actual],[Measures].[Turnover PrevYear]}
on Columns,
non empty{[Store].[Country].[Country].&[GERMANY]}
on Rows
from [Sales Cube]
where (
[Date].[Year - Quarter - Month - Date].[Month].&[2020]&[1],
[Store Status].[Store Status Type].&[Comparable]
)
How can I sum on Country-Level only the comparable stores?