對於我的報告,我需要選擇從數據庫動態訪問哪些列。更precice:SSRS選擇動態列
在數據庫中的列被命名爲這樣的:
FCST_Sales_2014_Q4_with_SF
FCST_Sales_2015_Q1_with_SF
FCST_Sales_2015_Q2_with_SF
FCST_Sales_2015_Q3_with_SF
我需要的報告選擇當前年份,季度,所以我使用的Now()
功能複合的表達我需要。例如:
=Year(Now())
而且
=Switch(
Month(Now()) = 1, 1,
Month(Now()) = 2, 1,
Month(Now()) = 3, 1,
Month(Now()) = 4, 2,
Month(Now()) = 5, 2,
Month(Now()) = 6, 2,
Month(Now()) = 7, 3,
Month(Now()) = 8, 3,
Month(Now()) = 9, 3,
Month(Now()) = 10, 4,
Month(Now()) = 11, 4,
Month(Now()) = 12, 4)
結果是2014
和4
這正是我需要的。如果我使用了以下內容:
=("Fields!FCST_Sales_" + CStr(Year(Now())) + "_Q" + CStr(Switch(Month(Now()) = 1, 1, Month(Now()) = 2,1,Month(Now()) = 3,1,Month(Now()) = 4, 2, Month(Now()) = 5,2,Month(Now()) = 6,2,Month(Now()) = 7,3,Month(Now()) = 8,3,Month(Now()) = 9,3,Month(Now()) = 10, 4, Month(Now()) = 11,4,Month(Now()) = 12,4)) + "_with_SF")
我得到正是我所需要的字符串(FCST_Sales_2014_Q4_with_SF
),但問題是,我有點不能使用.Value
操作。如果我將Sum()
和.Value
添加到我創建的表達式中,我收到錯誤消息,那.Value
不是String的成員。我使用的表達式是:
=Sum(("Fields!FCST_Sales_" + CStr(Year(Now())) + "_Q" + CStr(Switch(Month(Now()) = 1,1, Month(Now()) = 2,1,Month(Now()) = 3,1,Month(Now()) = 4,2, Month(Now()) = 5,2,Month(Now()) = 6,2,Month(Now()) = 7,3,Month(Now()) = 8,3,Month(Now()) = 9,3,Month(Now()) = 10, 4, Month(Now()) = 11,4,Month(Now()) = 12,4)) + "_with_SF").Value)
是否有解決此問題的方法?
,完美的工作,也是你的簡化的表達是非常有益的。謝謝你的幫助。 – Maierlu 2014-10-09 06:08:27