Ardalan Shahgholi
Ardalan Shahgholi

Reputation: 12575

Query (2, 2) By default, a year level was expected. No such level was found in the cube.ytd Function In MDX Query Not Work

I use SSAS and SQL Server 2008 R2 and AdventureWorks Database.

I write this query :

Select
ytd([Date].[Calendar].[Calendar Quarter].[Q3 CY 2003]) on columns
From [Adventure Works]

and i get this result :

enter image description here

but when i execute this query :

Select
ytd([Date].[Fiscal].[Fiscal Quarter].[Q3 FY 2003]) on columns
From [Adventure Works]

i get this error :

Executing the query ...
Query (2, 2) By default, a year level was expected. No such level was found in the cube.

Execution complete

why this query not work ?

Upvotes: 3

Views: 1909

Answers (1)

Marc Polizzi
Marc Polizzi

Reputation: 9375

From the documentation : The Ytd function is a shortcut function for the PeriodsToDate [...] .Note that this function will not work when the Type property is set to FiscalYears. How about using the following instead :

Select

  PeriodsToDate(
    [Date].[Fiscal].[Fiscal Year],
    [Date].[Fiscal].[Fiscal Quarter].[Q3 FY 2003]
  ) on columns

From [Adventure Works]

Upvotes: 6

Related Questions