BIRT Expression to Filter Data Based on Consecutive Instances [message #1868418] |
Thu, 18 July 2024 11:34  |
Eclipse User |
|
|
|
I'm working on a BIRT report and need help refining a data filtering expression.
Problem:
I have an existing BIRT template (.rptdesign) and sample XML data.
I've removed the first two columns from the report.
The goal is to display only rows where a specific value occurs 7 or more consecutive times.
Attempts:
I've created a BIRT expression but it's not producing the desired results.
Computed Column Name is *maxConsecutiveDays*, data type is *Integer*
var consecutiveDays = 0;
var maxConsecutiveDays = 0;
var lastDate = null;
for (var i = 0; i < dataSetRow["CalendarDate"].length; i++) {
var currentDate = new Date(dataSetRow["CalendarDate"][i]);
if (lastDate) {
var diffDays = (currentDate - lastDate) / (1000 * 60 * 60 * 24);
if (diffDays === 1) {
consecutiveDays++;
} else {
if (consecutiveDays > maxConsecutiveDays) {
maxConsecutiveDays = consecutiveDays;
}
consecutiveDays = 1;
}
} else {
consecutiveDays = 1;
}
lastDate = currentDate;
}
if (consecutiveDays > maxConsecutiveDays) {
maxConsecutiveDays = consecutiveDays;
}
maxConsecutiveDays;
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06380 seconds