Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Is it possible to sort data prior to computing columns?(Customer sorting)
Is it possible to sort data prior to computing columns? [message #1227149] Fri, 03 January 2014 17:31 Go to next message
Sebi F is currently offline Sebi FFriend
Messages: 1
Registered: January 2014
Junior Member
I have a requirement to create a report that shows 12 numerical columns out of which half are computed based on the other half (sums, percentages). The report has 24 rows, showing one row for each hour of the day. That I have been able to do easily.
However, the hours should be rolling, e.g. if now was 17:42 -> starting from yesterday at 18 and going to today at the current hour:

HOUR | COL1 | CUMULATIVE_COL
18 3 267
19 2 269
20 3 272
21 4 276
22 9 285
23 6 291
0 12 12
1 8 20
2 9 29
3 12 41
...
15 18 236
16 12 248
17 16 264

I've been able to do this in SQL but unfortunately not all hours have data so those hours I could not sort properly.

As a workaround I tried to sort the rows in BIRT but it seems to be done after the columns are computed so the cumulative columns do no start properly (as seen above).

What I want be able to shown instead:
HOUR | COL1 | CUMULATIVE_COL
18 3 3
19 2 5
20 3 8
21 4 12
22 9 21
23 6 27
0 12 39
1 8 47
2 9 56
3 12 68
...
15 18 263
16 12 275
17 16 291

Any thoughts on this would be much appreciated.
Re: Is it possible to sort data prior to computing columns? [message #1229171 is a reply to message #1227149] Wed, 08 January 2014 21:36 Go to previous message
Vassili Safonov is currently offline Vassili SafonovFriend
Messages: 7
Registered: May 2013
Junior Member
Do everything in SQL.


declare @hr_cnt int,
    @start_hr int,
    @hr_add int

create table #tmp_tbl(
hr_num int identity,
hr int,
vl int null
)

select  @hr_cnt = 0, @hr_add = 0
select @start_hr = datepart(hh,getdate())

while @hr_cnt < 24
begin
    if @start_hr+@hr_add > 23
        select  @start_hr = 0,@hr_add = 0

    insert #tmp_tbl
    select @start_hr+@hr_add, @hr_cnt --mock values

    select  @hr_cnt = @hr_cnt + 1,@hr_add  = @hr_add + 1
end


-- This is your final select. everything before is just a prep for this example
select a.hr_num, a.hr,a.vl,sum(b.vl) s_vl
from #tmp_tbl a,#tmp_tbl b
where b.hr_num <= a.hr_num
group by a.hr_num, a.hr,a.vl
order by 1

drop table #tmp_tbl

Previous Topic:Sort Crosstab with several criteria
Next Topic:Necessary permissions for BIRT in server.policy file
Goto Forum:
  


Current Time: Fri Apr 19 08:08:51 GMT 2024

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

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

Back to the top