I'm working on a report in Reporting Services and I can't figure out why I'm having trouble with Non-queried report parameters.
我正在编写Reporting Services中的报告,我无法弄清楚为什么我遇到了非查询报告参数的问题。
I'm trying to get the current year and have tried:
我正试图获得当前年份并尝试过:
=YEAR(TODAY())
=DATEPART("yyyy",TODAY())
I have also tried TODAY instead of TODAY()
我也试过TODAY而不是TODAY()
All of these seem to break the Year dropdown on my report. I thought if something was wrong it would just not get the correct default... but nope, it breaks the whole field.
所有这些似乎打破了我的报告的年度下降。我认为如果出现问题,它将无法获得正确的默认值......但是不,它打破了整个领域。
Any thoughts? articles?
有什么想法吗?文章?
UPDATE:
Wait, wait, wait... the weirdest thing. The Year parameter is the second parameter of this report. And its grayed out (with no value) UNTIL I select the first parameter (im my case "category"). Am I somehow telling the Year param to do this? or does SSRS 2005 process the params in order? I don't think I ever noticed this before.
更新:等待,等待,等待......最奇怪的事情。 Year参数是此报告的第二个参数。并且它变灰(没有值)UNTIL我选择第一个参数(我的情况是“类别”)。我是否以某种方式告诉年度干事这样做?或者SSRS 2005是否按顺序处理了参数?我不认为我以前曾经注意过这一点。
UPDATE 2:
Please see all comments
更新2:请查看所有评论
5 个解决方案
#1
=DateTime.Today.Year
should work as well.
也应该工作。
Edit: Bruno - i have the same behavior as you are seeing. I created a sample report with a string first parameter with no default value, and a string 2nd parameter with a default of =DateTime.Today.Year. When I have the one with the default as the 2nd parameter in the order, it shows up empty and disabled.
编辑:布鲁诺 - 我有与你看到的相同的行为。我创建了一个示例报表,其中包含一个没有默认值的字符串第一个参数,以及一个默认值为= DateTime.Today.Year的字符串第二个参数。当我将默认值作为订单中的第二个参数时,它显示为空和禁用。
I was able to fix this problem 2 ways: first by adding a default of =String.Empty to my first parameter, and the second way was to just change the order of the parameters.
我能够通过两种方式解决这个问题:首先在我的第一个参数中添加一个默认值= String.Empty,第二种方法是改变参数的顺序。
Not sure if this behavior is by design or a bug - but like you said, I hadn't noticed it either until today when you pointed it out in your question.
不确定这种行为是设计还是错误 - 但就像你说的那样,直到今天你在你的问题中指出它时我才注意到它。
#2
Try:
=Year(Now)
I'm not sure if this is what you need, but it worked for me. I used it to form a date string so I used =Year(Now).ToString().
我不确定这是否是你需要的,但它对我有用。我用它来形成一个日期字符串,所以我使用了= Year(Now).ToString()。
#3
SSRS does process the report parameters in order - order can be important if you have dependencies between your parameters.
SSRS会按顺序处理报告参数 - 如果您的参数之间存在依赖关系,则顺序非常重要。
From MSDN: "Parameter order is important when you have cascading parameters, or when you want to show users the default value for one parameter before they choose values for other parameters."
来自MSDN:“当您有级联参数时,或者当您希望在为其他参数选择值之前向用户显示一个参数的默认值时,参数顺序很重要。”
So, it will always wait until you have a default value for your first parameter or you enter the first parameter's value, before it processes the next one, and so on.
因此,它将始终等到您的第一个参数具有默认值,或者在处理下一个参数之前输入第一个参数的值,依此类推。
#4
I found the by making sure that ALL of my parameters had at least some default value, then you will not experience they greyed out datetime picker. So, every parameter before your datetime paremeter in order needs to have a (default) value or it will not work.
我发现确保所有参数都至少有一些默认值,然后你就不会遇到灰色日期时间选择器。因此,您的日期时间参数之前的每个参数都需要具有(默认)值,否则它将无法工作。
#5
Def due to order of evaluation of parameters.
由于参数评估顺序而导致Def。
Simple workaround ; in the parameters tab you can change the order of the parameters - this will move the date pickers to the top of the list and are then enabled straight away, on my server at least.
简单的解决方法;在参数选项卡中,您可以更改参数的顺序 - 这会将日期选择器移动到列表顶部,然后立即启用,至少在我的服务器上。
Someone raised the issue of basing a date filter on a queried default value - if you do this, you will notice a very annoying knock-on effect of getting screen refresh any time the dates get changed, before you have a chance to requery the reports.
有人提出了一个基于查询默认值的日期过滤器的问题 - 如果这样做,你会发现在你有机会重新查询报告之前,在日期变更时获得屏幕刷新的非常烦人的连锁效应。
#1
=DateTime.Today.Year
should work as well.
也应该工作。
Edit: Bruno - i have the same behavior as you are seeing. I created a sample report with a string first parameter with no default value, and a string 2nd parameter with a default of =DateTime.Today.Year. When I have the one with the default as the 2nd parameter in the order, it shows up empty and disabled.
编辑:布鲁诺 - 我有与你看到的相同的行为。我创建了一个示例报表,其中包含一个没有默认值的字符串第一个参数,以及一个默认值为= DateTime.Today.Year的字符串第二个参数。当我将默认值作为订单中的第二个参数时,它显示为空和禁用。
I was able to fix this problem 2 ways: first by adding a default of =String.Empty to my first parameter, and the second way was to just change the order of the parameters.
我能够通过两种方式解决这个问题:首先在我的第一个参数中添加一个默认值= String.Empty,第二种方法是改变参数的顺序。
Not sure if this behavior is by design or a bug - but like you said, I hadn't noticed it either until today when you pointed it out in your question.
不确定这种行为是设计还是错误 - 但就像你说的那样,直到今天你在你的问题中指出它时我才注意到它。
#2
Try:
=Year(Now)
I'm not sure if this is what you need, but it worked for me. I used it to form a date string so I used =Year(Now).ToString().
我不确定这是否是你需要的,但它对我有用。我用它来形成一个日期字符串,所以我使用了= Year(Now).ToString()。
#3
SSRS does process the report parameters in order - order can be important if you have dependencies between your parameters.
SSRS会按顺序处理报告参数 - 如果您的参数之间存在依赖关系,则顺序非常重要。
From MSDN: "Parameter order is important when you have cascading parameters, or when you want to show users the default value for one parameter before they choose values for other parameters."
来自MSDN:“当您有级联参数时,或者当您希望在为其他参数选择值之前向用户显示一个参数的默认值时,参数顺序很重要。”
So, it will always wait until you have a default value for your first parameter or you enter the first parameter's value, before it processes the next one, and so on.
因此,它将始终等到您的第一个参数具有默认值,或者在处理下一个参数之前输入第一个参数的值,依此类推。
#4
I found the by making sure that ALL of my parameters had at least some default value, then you will not experience they greyed out datetime picker. So, every parameter before your datetime paremeter in order needs to have a (default) value or it will not work.
我发现确保所有参数都至少有一些默认值,然后你就不会遇到灰色日期时间选择器。因此,您的日期时间参数之前的每个参数都需要具有(默认)值,否则它将无法工作。
#5
Def due to order of evaluation of parameters.
由于参数评估顺序而导致Def。
Simple workaround ; in the parameters tab you can change the order of the parameters - this will move the date pickers to the top of the list and are then enabled straight away, on my server at least.
简单的解决方法;在参数选项卡中,您可以更改参数的顺序 - 这会将日期选择器移动到列表顶部,然后立即启用,至少在我的服务器上。
Someone raised the issue of basing a date filter on a queried default value - if you do this, you will notice a very annoying knock-on effect of getting screen refresh any time the dates get changed, before you have a chance to requery the reports.
有人提出了一个基于查询默认值的日期过滤器的问题 - 如果这样做,你会发现在你有机会重新查询报告之前,在日期变更时获得屏幕刷新的非常烦人的连锁效应。