set databand filter based on variable value
set databand filter based on variable value
Hello,
I am working on a report where user can choose to display data based on 1 of 2 date ranges - fiscal year or calendar year.
Fiscal Year runs from October 1 of one year to September 30 of the following year. I have "Fiscal Year" and "Calendar Year"
as options in a variable called rptReportPeriod and I have Request Parameters set to True for the report.
I can use expression A below in a Databand filter to limit information for the Fiscal Year or expression B. to limit the information for the Calendar year.
(rptYear is another variable that users can enter a year into).
A. WorkOrders.BeginDate >= DateTime.ParseExact("10/01/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
&& WorkOrders.BeginDate <= DateTime.ParseExact("09/30/" + (int.Parse(rptYear) + 1).ToString(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
B. WorkOrders.BeginDate >= DateTime.ParseExact("01/01/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
&& WorkOrders.BeginDate <= DateTime.ParseExact("12/31/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
What I'd like to be able to do is use an IIF statement to apply the proper expression based on the rptReportPeriod variable. Something like...
IIF(rptPeriod == "Fiscal Year",
WorkOrders.BeginDate >= DateTime.ParseExact("10/01/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture) && WorkOrders.BeginDate <= DateTime.ParseExact("09/30/" + (int.Parse(rptYear) + 1).ToString(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture),
WorkOrders.BeginDate >= DateTime.ParseExact("01/01/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture) && WorkOrders.BeginDate <= DateTime.ParseExact("12/31/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture))
The above expression doesn't work though - it gives a generic Error #2032 and the More Details button just says "Server Message is Empty".
Is there a way to do what I'd like - perhaps with the use of additional variables and the Begin Render events of the report and/or databand?
I am working on a report where user can choose to display data based on 1 of 2 date ranges - fiscal year or calendar year.
Fiscal Year runs from October 1 of one year to September 30 of the following year. I have "Fiscal Year" and "Calendar Year"
as options in a variable called rptReportPeriod and I have Request Parameters set to True for the report.
I can use expression A below in a Databand filter to limit information for the Fiscal Year or expression B. to limit the information for the Calendar year.
(rptYear is another variable that users can enter a year into).
A. WorkOrders.BeginDate >= DateTime.ParseExact("10/01/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
&& WorkOrders.BeginDate <= DateTime.ParseExact("09/30/" + (int.Parse(rptYear) + 1).ToString(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
B. WorkOrders.BeginDate >= DateTime.ParseExact("01/01/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
&& WorkOrders.BeginDate <= DateTime.ParseExact("12/31/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
What I'd like to be able to do is use an IIF statement to apply the proper expression based on the rptReportPeriod variable. Something like...
IIF(rptPeriod == "Fiscal Year",
WorkOrders.BeginDate >= DateTime.ParseExact("10/01/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture) && WorkOrders.BeginDate <= DateTime.ParseExact("09/30/" + (int.Parse(rptYear) + 1).ToString(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture),
WorkOrders.BeginDate >= DateTime.ParseExact("01/01/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture) && WorkOrders.BeginDate <= DateTime.ParseExact("12/31/" + rptYear, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture))
The above expression doesn't work though - it gives a generic Error #2032 and the More Details button just says "Server Message is Empty".
Is there a way to do what I'd like - perhaps with the use of additional variables and the Begin Render events of the report and/or databand?
Re: set databand filter based on variable value
Hello,
Please clarify which version and which component (flash or HTM5) are you use?
If possible, please send us a simple report with test data which reproduces the issue for analysis.
Thank you.
Please clarify which version and which component (flash or HTM5) are you use?
If possible, please send us a simple report with test data which reproduces the issue for analysis.
Thank you.
Re: set databand filter based on variable value
Thanks for the reply Aleksey, I'll send the sample and data to support@stimulsoft.com. I created a simple report that demonstrates the issue.
In the sample, I entered expression A from above as a databand filter so I could save the report. When I try to enter the expression with the IIF
statement as the databand filter, I'm now getting a cannot convert object to bool error so there may be a couple of issues going on.
I'm using Stimulsoft Reports.Web 2015.3 with Flash Player 26 for Windows.
In the sample, I entered expression A from above as a databand filter so I could save the report. When I try to enter the expression with the IIF
statement as the databand filter, I'm now getting a cannot convert object to bool error so there may be a couple of issues going on.
I'm using Stimulsoft Reports.Web 2015.3 with Flash Player 26 for Windows.
Re: set databand filter based on variable value
Hello,
Thank you for the information.
We will reply by email at the ticket system.
Thank you.
Thank you for the information.
We will reply by email at the ticket system.
Thank you.
Re: set databand filter based on variable value
Hello Carl,
In the flash version are not supported all methods from the .NET framework.
In your case, you can try to use the following expression:
Thank you.
In the flash version are not supported all methods from the .NET framework.
In your case, you can try to use the following expression:
Code: Select all
{WorkOrders.BeginDate >= DateSerial(rptYear,1,10) && WorkOrders.BeginDate <= DateSerial(rptYear+1,9,30)}
Re: set databand filter based on variable value
Thanks Aleksey,
With help from you and Alex Kulikow, we came up with the following expression that works.
(rptPeriod == "Fiscal Year" ? WorkOrders.BeginDate >= DateSerial(rptYear,10,1) && WorkOrders.BeginDate <= DateSerial(rptYear + 1,9,30) :
WorkOrders.BeginDate >= DateSerial(rptYear,1,1) && WorkOrders.BeginDate <= DateSerial(rptYear,12,31))
As always, I appreciate the help you provide.
Carl
With help from you and Alex Kulikow, we came up with the following expression that works.
(rptPeriod == "Fiscal Year" ? WorkOrders.BeginDate >= DateSerial(rptYear,10,1) && WorkOrders.BeginDate <= DateSerial(rptYear + 1,9,30) :
WorkOrders.BeginDate >= DateSerial(rptYear,1,1) && WorkOrders.BeginDate <= DateSerial(rptYear,12,31))
As always, I appreciate the help you provide.
Carl
Re: set databand filter based on variable value
Hello Carl
We are always glad to help you!
Please let us know if you need any additional help.
Thank you.
We are always glad to help you!
Please let us know if you need any additional help.
Thank you.