简体   繁体   English

在SSRS中使用DAX查询的日期范围

[英]Date range using DAX query in SSRS

I am using SSRS 2015 to create a report. 我正在使用SSRS 2015创建报告。 The data is sourced from a tabular cube so I used a DAX query to create the shared dataset. 数据来自表格多维数据集,因此我使用了DAX查询来创建共享数据集。 What I am trying to do is add parameters to my report which would allow users to filter the data according to their date range using the calendar picker. 我想做的是在我的报表中添加参数,该参数允许用户使用日历选择器根据日期范围过滤数据。 I tried: 我试过了:

EVALUATE
FILTER(
SUMMARIZE(
  'PurchaseTable'
  ,'PurchaseTable'[Invoice Date]
),
  'PurchaseTable'[Invoice Date] >= DATEVALUE(FORMAT(@FromDate, "dd/MM/yyyy"))
  && 'PurchaseTable'[Invoice Date] <= DATEVALUE(FORMAT(@ToDate, "dd/MM/yyyy"))
)

But it produced an error: The following system error occurred: Type mismatch 但是它产生了一个错误: 发生以下系统错误:类型不匹配

I also tried: 我也尝试过:

  'PurchaseTable'[Invoice Date] >= @FromDate
  && 'PurchaseTable'[Invoice Date] <= @ToDate

and get the following error: DAX comparison operations do not support comparing values of type Date with values of type Text 并得到以下错误: DAX比较操作不支持将Date类型的值与Text类型的值进行比较

My PurchaseTable[Invoice Date] column is of date type in dd/MM/yyyy format. 我的PurchaseTable [Invoice Date]列的日期类型为dd / MM / yyyy。 Thank you in advance for any help. 预先感谢您的任何帮助。

If you are comfortable with adding parameters to DAX after playing around with SSRS, the following should be the code for your final DAX. 如果您在使用SSRS之后对在DAX中添加参数感到满意,则以下应为最终DAX的代码。

EVALUATE(
FILTER(
SUMMARIZE(
  'PurchaseTable'
  ,'PurchaseTable'[Invoice Date]
),
  'PurchaseTable'[Invoice Date] >= VALUE(@FromDate)
  && 'PurchaseTable'[Invoice Date] <= VALUE(@ToDate)
))

Make sure that your parameters are always of date type. 确保您的参数始终为日期类型。

Hope this help? 希望有帮助吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM