Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Birt report - COUNTIF - count the number of times it matches a criteria
Birt report - COUNTIF - count the number of times it matches a criteria [message #1740110] Tue, 09 August 2016 11:24 Go to next message
Diogo Santos is currently offline Diogo SantosFriend
Messages: 4
Registered: August 2016
Junior Member
╔══╦══╦═══╗
║id.║TV#║Time║
╠══╬══╬═══╣
║01║TV1║ 00 ║
║02║TV2║ 10 ║
║03║TV3║ 00 ║
║04║TV3║ 20 ║
║05║TV3║ 21 ║
║ ... ║ .... ║ ... ║
╚══╩══╩══╝
Hi, I'm new to Birt, maybe this is too numb but:
I want to count the number of elements id, for each TV#, which time > 0. In this case, I want the result to be:

TV1 - 0 ; TV2 - 1; TV3 - 2

I'm using BIRT Report, and I've tried different ways to get this, but I couldnt get what I want.

I've tried different ways, this is what I'm using at the moment:

Data Cube, Summary fields (measure)

Function: Count

Expression: measure["id"]

Filter: measure["Time"]>0

And then I'm using an Aggregation Builder:

Function:Count or Sum

Expression:measure["id"]

Filter: measure["Time"]>0

Aggregate on: GroupTV#

When I use count, this is returning: only 0s and 1s (it gives me "1" to TV# when there is at least one Time>0), ie TV1 - 0 ; TV2 - 1; TV3 - 1

When I use sum, this is returning: the number of times each TV# appears on the table (when there is at least one Time>0 for that channel), ie TV1 - no output ; TV2 - 1; TV3 - 3

I want something like COUNTIF

Can someone help me?

[Updated on: Wed, 10 August 2016 16:36]

Report message to a moderator

Re: Birt report - count the number of times it matches a criteria [message #1740207 is a reply to message #1740110] Wed, 10 August 2016 12:56 Go to previous messageGo to next message
Lucas Kaltenbrunner is currently offline Lucas KaltenbrunnerFriend
Messages: 2
Registered: August 2016
Location: Austria
Junior Member
Sorry I´m also new to BIRT but I hope i can help you a little bit.
Example:
I used a Flat File Data Source (.csv) with the following Data:
ID,TV#,Time
01,TV1,0
02,TV1,0
03,TV2,0
04,TV2,1
05,TV2,1
06,TV2,1
07,TV3,0
08,TV3,0
09,TV3,0
10,TV3,3
11,TV3,3

IN BIRT:
Aggregation Builder:
Data Type: Integer
Function: Count
Expression:
Filter: dataSetRow["Time"] >0 && dataSetRow["TV#"] == "TV1"
Result: 0
Filter: dataSetRow["Time"] >0 && dataSetRow["TV#"] == "TV2"
Result: 3
Filter: dataSetRow["Time"] >0 && dataSetRow["TV#"] == "TV3"
Result: 2

That´s all i got in 1 Minute because i have to go.
Hope it helped at least a little bit.


Re: Birt report - count the number of times it matches a criteria [message #1740217 is a reply to message #1740207] Wed, 10 August 2016 14:14 Go to previous messageGo to next message
Diogo Santos is currently offline Diogo SantosFriend
Messages: 4
Registered: August 2016
Junior Member
Thanks Lucas,

That is the type of results that I want (with the data that you used).
But it didn't work for me.

When I try to leave the expression field empty, I got always this error message: org.eclipse.birt.report.service.api.ReportServiceException: Error happened while running the report.

When I try to use Expression: measure["TV#"], the table doesn't appear on Preview tab.

Furthermore, I'm using a cross tab, so I can't define an expression like Filter: dataSetRow["Time"] >0 && dataSetRow["TV#"] == "TV1" for each TV#... I need a global expression, to match all TV# that are available on the cross tab.

Re: Birt report - count the number of times it matches a criteria [message #1740305 is a reply to message #1740217] Thu, 11 August 2016 11:40 Go to previous message
Diogo Santos is currently offline Diogo SantosFriend
Messages: 4
Registered: August 2016
Junior Member
Solved. Instead of using filters on Data Cube, or on Cross Tabs or on Charts, just filter on Data Sets.

Previous Topic:About BIRT 4.6 Pre-requisites
Next Topic:Is there anyway to mask a field?
Goto Forum:
  


Current Time: Fri Aug 23 14:07:22 GMT 2019

Powered by FUDForum. Page generated in 0.02226 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top