Community
Participate
Working Groups
I have group “MonthGroup” and subgroup “InsuranceGroup”. I need to calculate total visits of patients in column “year to date” for both group. For first group (“MonthGroup”) it was easy. I just made this expression: Total.runningSum(row["VisitCount"], null, 0) But I can’t figure out how to get that for second group (“InsuranceGroup”). Let say for the first month we have 10 medicaid's patients visits. On the second month we got 13 medicaid's patients visits. In report we need to see something like this: Month Total YTD ------------------------- January medicaid 10 10 medicare 5 5 total 15 15 ------------------------- February medicaid 13 23 medicare 7 12 total 20 35 ------------------------- March medicaid 11 34 medicare 6 18 total 17 52 ------------------------- I have the following expressions: Total By Insurance: Total.Sum(row["VisitCount"], null, "InsuranceGroup") Total By Month: Total.Sum(row["VisitCount"], null, "InsuranceGroup") Year To Date Total By Month: Total.runningSum(row["VisitCount"], null, 0) Year To Date Total By Insurance: Can't find correct expression!!! I found some information regarding nested total expressions here: http://dev.eclipse.org/mhonarc/lists/birt-dev/msg05295.html But I’m still stuck. The birt’s documentation is lack of information, how to use “Total.runningSum” function on subgroup level. In case if exists possibility to calculate Total.runningSum for subgroup please put corresponding information in the manual. And don't forget describe that to me :) In case if no way to calculate running sum for subgroup using birt's functions it makes sense to do some improvements for aggregate framework.
Rather interesting case ;-) One solution to the problem is that use "filter" in aggregation. Say, Total.runningSum(row["VisitCount"], row["Insurance"]=="medicaid", 0) and Total.runningSum(row["VisitCount"], row["Insurance"]=="medicare", 0). The other solution is to define a computed column using java script in data set's predefined method.Say, we define a computed column "RunningSum", the pseudocode could like follows: in open method: --------------------------------------- Map month = new HashMap(); --------------------------------------- in fetch method --------------------------------------- if( month.get(row["Month"]) == null ) month.put(row["Month"]); var tempMap = month.get(row["Month"]); var count = 1; if( tempMap.get(row["Insurance"]) == null ) { tempMap.put(count); }else { count = tempMap.get(row["Insurance"]) + 1; tempMap.put(row["Insurance"], count); } row["RunningSum"] = count; --------------------------------------- The other solution I can figure out so far is similar to above ones. These solutions are either incomprehensive or not easy to implement. We will continue investigating.
Thank you Lin for trying to provide at least temporary solutions. I will take your second solution as work around in my report. You probably will agree with me that group identifier as third argument useless in current implementation of "Total.runningSum" method. I mean we can use "Total.runningSum" only with group identifier equal to zero. I suggest to change current implementation of the method such way that defining group identifier will be enough to calculate running sum correctly regarding to selected group. This behavior will be consistent with others aggregate related methods. For example such method as "Total.sum" acting this way. Examples: Total.runningSum(row["VisitCount"], null, "MonthGroup") Total.runningSum(row["VisitCount"], null, "InsuranceGroup") Of course implementation of the method will be more compicated because you have to take into account hierarchy of the groups. You did this in second solution creating the map of month.
After some thinking I realized that group parameter still in using to define running scope of the method. That means my previous suggestion will create much confusion in case it accepted. What if we introduce additional parameter to the "Total.sumRrunning" that will define if running sum must take into account hierarchy of groups. Lets call related to group parameters "topGroup" and "bottomGroup" respectively. If value of the "bottomGroup" is defined running sum will calculate value respective to group hierarchy defined by "topGroup" and "bottomGroup" parameters. Suggested synopsis: Total.first( expr [, filter [, topGroup [,bottomGroup] ]] ) If the birt team will accept the last suggestion I would able to solve the problem with the following expression: Total.Sum(row["VisitCount"], null, 0, "InsuranceGroup")
Thank you for your insight this far to the problem. Actually the problem only happens to Running aggregations such as running sum (Though running aggregations are not initially designed to handle this sort of problem).This kind of aggregations has some usage that cannot be covered by BIRT's current aggregation framework. This bug is a case. We will investigate this issue to see what we can do to such a usage.
*** Bug 173903 has been marked as a duplicate of this bug. ***
After discussion we defer this bug to post 2.2.0.
add plan keyword to consider this enhancement for next release