订阅具有不同默认参数的报告 [英] Subscribing to a report with different default parameters

查看:115
本文介绍了订阅具有不同默认参数的报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2013中创建了一个报告.我还创建了一个存储过程,该过程返回一个计算出Last_week_start,Last_week_finish,Last_month_start,Last_month_finish等的数据集.我这样做是为了让用户可以订阅这些报告,并在每周的星期一和1日通过电子邮件将其发送给他们.每月的月度报告.我是否必须使用不同的默认参数为每周和每月报告创建单独的报告?即审核报告(每周一次)和审核报告(每月一次)并维护2个报告,或者是否有更动态的方式来做到这一点

I have created a report in VS2013. I have also created a Stored procedure that returns a dataset that works out Last_week_start, Last_week_finish, Last_month_start, Last_month_finish etc. I have done this so users can subscribe to these reports and get them emailed to them on a Monday for the weekly and on the 1st on the month for the monthly reports. Do I have to create separate reports for the weekly and monthly reports with different default parameters? ie Audit Report (weekly) and Audit Report (monthly) and maintain 2 reports or is there a more dynamic way to do this

推荐答案

我要允许最终用户订阅的报告的处理方式,默认日期值取决于订阅是每天,每周还是每天,或者说每月一次,将有一个额外的参数使之成为可能.

The way I have handled reports that I want to allow end users to subscribe to, and have the default date values vary depending on whether subscription was a daily, weekly, or monthly one, is to have an extra parameter that makes this possible.

我添加到报告中的参数是我称为期间(或报告期间)的参数,它必须是报告中的第一个参数,或者至少在日期参数之前列出.此参数的下拉列表中的唯一值是每日",每周"和每月"(或任何适用的值).这些可以是您所需要的.手动将它们作为值选项输入报表的参数中,因为预计它们不会经常更改.根据最终用户在创建订阅时为该参数选择的内容,默认日期值会更改.这是通过日期参数默认值中的表达式来完成的,该表达式评估从期间"下拉列表中选择的值.

The parameter I add to the report is one I call Period (or Report Period), and it has to be the first parameter in the report, or at least listed before the date parameters. The only values in the dropdown for this parameter are Daily, Weekly, and Monthly (or whatever is applicable). These can be whatever you need. Enter these manually as value options in the parameter in the report, since they are not expected to change very often. Based on what the end user chooses for this parameter when creating a subscription, the default date values change. This is done via an expression in the default value for the date parameters that evaluates the value chosen from the Period dropdown.

因此,如果最终用户想要每日订阅,则可以从期间"参数下拉列表中选择每日",并且开始日期和结束日期参数的默认值将更改为仅包括前一天.如果他们选择每周",则开始日期和结束日期参数将更改为仅包括前一周,依此类推.

So, if the end user wants a daily subscription, they choose Daily from the Period parameter dropdown, and the default values for the start and end date parameters change to only include the prior day. If they choose Weekly, the start and end date parameters change to only include the prior week, and so on.

以下是开始日期参数默认值表达式的示例.

Here is an example for the start date parameter default value expression.

=Switch(Parameters!Period.Value = "Daily" , DateAdd(DateInterval.Day, -1, Today), 
Parameters!Period.Value = "Weekly" , DateAdd(DateInterval.WeekOfYear, -1, DateAdd(DateInterval.Day, -(DatePart(DateInterval.Weekday, Today, 0, 0)-1), Today)) , 
Parameters!Period.Value = "Monthly" , DateAdd(DateInterval.Month, -1, DateAdd(DateInterval.Day, -(DatePart(DateInterval.Day, Today, 0, 0)-1), Today)))

有关结束日期参数...

For the end date parameter…

=Switch(Parameters!Period.Value = "Daily" , Today, 
Parameters!Period.Value = "Weekly" , DateAdd(DateInterval.Day, -(DatePart(DateInterval.Weekday, Today, 0, 0)), Today) , 
Parameters!Period.Value = "Monthly" , DateAdd(DateInterval.Day, -(DatePart(DateInterval.Day, Today, 0, 0)), Today))

警告!在报表设计器(预览)中或在线更改期间"值都不会导致日期值自动在您眼前改变.但是,它将在创建(并因此执行)预订的同时.我从来没有研究过为什么.

Warning!! Changing the Period value either in the report designer (preview), or online, will not cause the date values to automatically change right before your eyes. It will while creating (and thus executing) a subscription, however. I have never looked into why this is.

一个报告,基于参数的动态日期范围.

One report, dynamic date ranges based on a parameter.

尝试一下.

这篇关于订阅具有不同默认参数的报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆