How to loop query with given parameters in Birt Report - birt

I Have made a report in birt.
The dataset of the report containing the query which contains many where conditions using a Startdate parameter.
I have made two parameters Startdate and Enddate. I want to loop that parameter from a Startdate parameter to Enddate parameter.
I want to run a single query with different parameter eveytime, Starting from Startdate till enddate

This can be done through beforeOpen Script of the data Set.

Related

Quicksight parse date into month

Maybe I missed it but I'm attempting to create a dynamic 'Month' parameter based on a datetime field - but can't seem to get just the month! ? Am I missing something ?
here's my source DTTM date/time field -
In Manage Data > Edit [selected] Data Set > Data source
Just add 'calculated field':
truncDate('MM', date)
where MM returns the month portion of the date.
See manual of truncDate function
The only place in Quicksight that you can get just a month, e.g. "September" is on a date-based axis of a visual. To do so, click the dropdown arrow next to the field name in the fields list, select "Format: (date)" then "More Formatting Options..." then "Custom" and enter MMMM in the Custom format input box.
Quicksight menu selection as described
This will then show the full month name on the date axis in your visual. NB It will use the full month name on this visual for ALL time period "Aggregations" - e.g. if you change the visual to aggregate by Quarter, it will display the full name of the quarter's first month etc.
If you are talking about "Parameters" in the Quicksight analysis view then you can only create a "Datetime" formatted parameter and then only use the "Date picker" box format for this parameter in a control (+ filter).
If you use a calculated field in either data preparation or analysis view the only date functions do not allow full month names as an output, you can get the month number as an integer or one of the allowed date formats here:
https://docs.aws.amazon.com/quicksight/latest/user/data-source-limits.html#supported-date-formats
You'll need to hardcode the desired results using ifelse, min, and extract.
Extract will pull out the month as an integer. Quicksight has a desire to beginning summing integers, so we'll put MIN in place to prevent that.
ifelse(min(extract('MM',Date)) = 1,'January',min(extract('MM',Date)) = 2,'February',min(extract('MM',Date)) = 3,'March',min(extract('MM',Date)) = 4,'April',min(extract('MM',Date)) = 5,'May',min(extract('MM',Date)) = 6,'June',min(extract('MM',Date)) = 7,'July',min(extract('MM',Date)) = 8,'August',min(extract('MM',Date)) = 9,'September',min(extract('MM',Date)) = 10,'October',min(extract('MM',Date)) = 11,'November',min(extract('MM',Date)) = 12,'December','Error')
Also, I apologize if this misses the mark. I'm not able to see the screeshot you posted due to security controls here at the office.
You can use the extract function. Works like this:
event_timestamp Nov 9, 2021
extract('MM', event_timestamp)
11
You can add a calculated field using the extract function:
extract returns a specified portion of a date value. Requesting a time-related portion of a date that doesn't contain time information returns 0.
extract('MM', date_field)

How to use bind variable in oracle report parameter form?

I have a parameter form with a value for the fiscal year and equipment ID. I want to populate the equipment ID list of values based on the fiscal year that is selected.
My query for the equipment ID list of values would be
SELECT EQPID,NAME FROM EQPLIST WHERE FY = :FY.
When I tried to add this query to the list of values of the equipment ID parameter I get
REP-0781: Bind variables are not allowed in the Select statement.
Is there a way to dynamically generate the list of values select statement in a reports trigger?
Cascading LoV, eh?
Which Reports version do you use? If it is 6i (client-server), I believe that your only resort is to create a parameter form using Oracle Forms, and then pass those parameters to a report.
If you're on a higher version (web-based), have a look at Metalink note 185951.1 ("How to create a parameter LOV based on another parameter value?") which includes sample code. Or, as above, create your own parameter form in Forms (that option works in any version).

Two dates difference in SpagoBI Studio javascript code?

I want to know the format to get the number of days between two dates in spagoBI studio?
I have StartDate and EndDate and I want to know the Number of days between these dates.
The first question to ask is what type of document are you creating in SpagoBI studio? Is it a BIRT or Jasper Report? It is a chart ? Almost everything coming in from a SpagoBI dataset is treated as a String.
If you were using JavaScript in a BIRT report, you would need to covert those ENDDATE And STARTDATE row values to equivalent JavaScript date objects before performing calculations .
What about modifying the dataset query to perform the date difference in SQL and pass that back as a column?

VS Problems with Dateadd function using parameters in a query

I am creating a report in MS Visual Studio 2008 epxress. The dataset should be limited using parameters. I want the users to have the ability to choose a starting date and then name the number of years into the future they want to see the data.
I created 3 parameters
1. fromdate (Type:Date/Time; visible): This is where they choose a date
2. futureyears (Type: Integer; internal): This is where they should write the number of years into the future
3. todate (Type: Date/Time; internal): This is an internal parameter with the following function as the default value:
=dateadd(DateInterval.Year,Parameters!futureyears.Value,Parameters!fromdate.Value).
fromdate and todate are then used in the query of the dataset to limit the data.
The following error appears when I try to preview this:
"The DefaultValue expression for the report parameter 'todate' contains an error: The expression that references the parameter 'futureyears' does not exist in the parameters collection. Letters in the names of parameters must be use in the correct case"
The thing is: The parameter "futureyears" does exist, when I write the function for the default value of todate, I choose it from the parameters section. so it is there.
I tried to run this report without the futureyears parameter and typed in a random number in the dateadd function. Without the parameter in question, the report runs fine. the problem must be the parameter "futureyears", but I don't know where the problem is. Thank you for your help.
I just figured out the answer myself. Leaving this here in case anyone has a similar problem.
In the parameters folder, the "futureyears" parameter was listed UNDER the "todate" parameter.
All I needed to do for it to work was shift the futureyears parameter ABOVE the todate parameter. Now the report runs fine.

Report parameters always using design time values

How do I get the report to use a design-time set value on first run, and then use whatever the user inputs for subsequent 'refreshes'?
I'm using .Net 4 and Telerik Q1 2013 Reporting controls.
I've created a report that has a StartDate and EndDate parameter, which is passed to a SQL query and returns relevant data.
To make it easier for the users to just open and run the report with minimal effort, the StartDate and EndDate have a default value, being set as the first and last day of the current month respectively.
This works great. However, if the user changes these values after the report is loaded, and tries to run the report for say the first to last day of the previous month, the query does not use the user-entered values. Instead it always uses the expression for what is supposed to be the default value.
The way I set the default value is by opening the ReportParameter Collection Editor (right-click in the report, click Report Parameters), and set the Value property of the parameters.
The StartDate is set to:
=StartOfCurrentMonth()
and EndDate is set to
=EndOfCurrentMonth()
Any help would be greatly appreciated!
Stephen,
What you've outlined here works for me, are you maybe not running the service pack? I set the Value property in the ReportParameter Collection editor to both StartDate and EndDate as:
='3/1/2013'
The preview of the Report runs immediately with the default values. I am able to change the values and preview the report fine.
I created a Windows Forms application that creates an instance of the report. When the report first renders, it renders with the default values and I am also able to change the values in the ReportViewer as an end user and re-render the report with no issues.
TopPageViews report = new TopPageViews();
InstanceReportSource reportSource = new InstanceReportSource();
reportSource.ReportDocument = report;
this.reportViewer1.ReportSource = reportSource;
this.reportViewer1.RefreshReport();

Resources