Я создал отчет SSRS, который показал данные из куба OLAP. В отчете есть некоторые параметры, и у многих из них есть «доступные» и «стандартные» значения, полученные с помощью запроса MDX.
В отчете также присутствуют следующие параметры:
@ Год, @ месяц, день @
Я вычисляю эти параметры, используя вчера как дату (NOW () - 1), получая значения из запроса MDX.
WITH MEMBER [Measures].[Full Date] as 'NOW()-1'
MEMBER [Measures].[Day] as 'DAY([Full Date])'
MEMBER [Measures].[Month] as 'MONTH([Full Date])'
MEMBER [Measures].[Year] as 'YEAR([Full Date])'
SELECT
{[Full Date],[Day],[Month],[Year]} ON COLUMNS
FROM [CallCenter]
Мне нужно заменить дату «СЕЙЧАС () - 1» на предыдущий рабочий день.
WITH MEMBER [Measures].[Full Date] as '[previous working day]'
В хранилище данных я создал процедуру хранения, которая рассчитывает предыдущий рабочий день.
DECLARE @yesterday date
SET @yesterday = DATEADD(day,-1,@date)
select
today = @date
,todayname = DATENAME(WEEKDAY,@date)
,yesterday = @yesterday
,yesterdayname = DATENAME(WEEKDAY,@yesterday)
,day = CASE
WHEN DATENAME(WEEKDAY,@yesterday) = 'Sunday'
THEN DATEADD(day,-2,@yesterday)
WHEN DATENAME(WEEKDAY,@yesterday) = 'Saturday'
THEN DATEADD(day,-1,@yesterday)
-- **************************
-- LUNEDI' DELL'ANGELO
-- **************************
WHEN @yesterday = DATEADD(day,1,intern.GetEasterSunday (Year(@yesterday)))
THEN DATEADD(day,-3,@yesterday)
-- **************************
-- CAPODANNO
-- **************************
WHEN MONTH(@yesterday) = 1 and DAY(@yesterday) = 1
THEN
CASE
WHEN DATENAME(weekday,@yesterday) = 'Monday'
THEN DATEADD(day,-3,@yesterday)
WHEN DATENAME(weekday,@yesterday) = 'Sunday'
THEN DATEADD(day,-2,@yesterday)
ELSE DATEADD(day,-1,@yesterday)
END
-- **************************
-- EPIFANIA
-- **************************
WHEN MONTH(@yesterday) = 6 and DAY(@yesterday) = 1
THEN
CASE
WHEN DATENAME(weekday,@yesterday) = 'Monday'
THEN DATEADD(day,-3,@yesterday)
WHEN DATENAME(weekday,@yesterday) = 'Sunday'
THEN DATEADD(day,-2,@yesterday)
ELSE DATEADD(day,-1,@yesterday)
END
-- **************************
-- FESTA DELLA LIBERAZIONE
-- **************************
WHEN MONTH(@yesterday) = 4 and DAY(@yesterday) = 25
THEN
CASE
WHEN DATENAME(weekday,@yesterday) = 'Monday'
THEN DATEADD(day,-3,@yesterday)
WHEN DATENAME(weekday,@yesterday) = 'Sunday'
THEN DATEADD(day,-2,@yesterday)
ELSE DATEADD(day,-1,@yesterday)
END
-- **************************
-- FESTA DEI LAVORATORI
-- **************************
WHEN MONTH(@yesterday) = 5 and DAY(@yesterday) = 1
THEN
CASE
WHEN DATENAME(weekday,@yesterday) = 'Monday'
THEN DATEADD(day,-3,@yesterday)
WHEN DATENAME(weekday,@yesterday) = 'Sunday'
THEN DATEADD(day,-2,@yesterday)
ELSE DATEADD(day,-1,@yesterday)
END
-- **************************
-- FESTA DELLA REPUBBLICA
-- **************************
WHEN MONTH(@yesterday) = 6 and DAY(@yesterday) = 2
THEN
CASE
WHEN DATENAME(weekday,@yesterday) = 'Monday'
THEN DATEADD(day,-3,@yesterday)
WHEN DATENAME(weekday,@yesterday) = 'Sunday'
THEN DATEADD(day,-2,@yesterday)
ELSE DATEADD(day,-1,@yesterday)
END
-- **************************
-- FERRAGOSTO
-- **************************
WHEN MONTH(@yesterday) = 8 and DAY(@yesterday) = 15
THEN
CASE
WHEN DATENAME(weekday,@yesterday) = 'Monday'
THEN DATEADD(day,-3,@yesterday)
WHEN DATENAME(weekday,@yesterday) = 'Sunday'
THEN DATEADD(day,-2,@yesterday)
ELSE DATEADD(day,-1,@yesterday)
END
-- **************************
-- FESTA DI OGNISSANTI
-- **************************
WHEN MONTH(@yesterday) = 11 and DAY(@yesterday) = 1
THEN
CASE
WHEN DATENAME(weekday,@yesterday) = 'Monday'
THEN DATEADD(day,-3,@yesterday)
WHEN DATENAME(weekday,@yesterday) = 'Sunday'
THEN DATEADD(day,-2,@yesterday)
ELSE DATEADD(day,-1,@yesterday)
END
-- **************************
-- IMMACOLATA CONCEZIONE
-- **************************
WHEN MONTH(@yesterday) = 12 and DAY(@yesterday) = 8
THEN
CASE
WHEN DATENAME(weekday,@yesterday) = 'Monday'
THEN DATEADD(day,-3,@yesterday)
WHEN DATENAME(weekday,@yesterday) = 'Sunday'
THEN DATEADD(day,-2,@yesterday)
ELSE DATEADD(day,-1,@yesterday)
END
-- **************************
-- NATALE
-- **************************
WHEN MONTH(@yesterday) = 12 and DAY(@yesterday) = 25
THEN
CASE
WHEN DATENAME(weekday,@yesterday) = 'Monday'
THEN DATEADD(day,-3,@yesterday)
WHEN DATENAME(weekday,@yesterday) = 'Sunday'
THEN DATEADD(day,-2,@yesterday)
ELSE DATEADD(day,-1,@yesterday)
END
-- **************************
-- SANTO STEFANO
-- **************************
WHEN MONTH(@yesterday) = 12 and DAY(@yesterday) = 26
THEN
CASE
WHEN DATENAME(weekday,@yesterday) = 'Monday'
THEN DATEADD(day,-3,@yesterday)
WHEN DATENAME(weekday,@yesterday) = 'Tuesday'
THEN DATEADD(day,-4,@yesterday)
ELSE DATEADD(day,-2,@yesterday)
END
ELSE @yesterday
END
Я не могу заменить дату «СЕЙЧАС () - 1» результатом процедуры сохранения.
Мне нужна помощь. Спасибо.