Fixed sub-totals when first line of data is incomplete #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In a cross-tab, when the "sub-totals" option is enabled for a given row, but the first line of data (of the current sub-totals group) is incomplete, the feature only compute sub-totals for data having non-null data in the first row.
I think this is because of how the sub-total line is created ; cells of that new sub-total line are based on the content of the first line, so if the first line contain "blank" cells, the object is null, and because of
subTotalLine[j].Element != null
the content of following cells will never be added.The code of my PR here take the possibility of having empty cells in account and will add the missing object in the sub-total at each line, and not only the first one.
Here is a view of what happens without the fix :
The first line and sub-totals lines missing are highlighted in orange
SQL to generate these data :
select 'Group 1' as Groups, 'Subgroup1' as Subgroups, 'Col3' as Col, 4 as value from dual union select 'Group 1' as Groups, 'Subgroup2' as Subgroups, 'Col1' as Col, 1 as value from dual union select 'Group 1' as Groups, 'Subgroup2' as Subgroups, 'Col2' as Col, 3 as value from dual union select 'Group 1' as Groups, 'Subgroup2' as Subgroups, 'Col3' as Col, 1 as value from dual union select 'Group 1' as Groups, 'Subgroup3' as Subgroups, 'Col2' as Col, 4 as value from dual union select 'Group 1' as Groups, 'Subgroup4' as Subgroups, 'Col1' as Col, 5 as value from dual union select 'Group 1' as Groups, 'Subgroup4' as Subgroups, 'Col3' as Col, 8 as value from dual union select 'Group 2' as Groups, 'Subgroup1' as Subgroups, 'Col1' as Col, 2 as value from dual union select 'Group 2' as Groups, 'Subgroup1' as Subgroups, 'Col3' as Col, 6 as value from dual union select 'Group 2' as Groups, 'Subgroup2' as Subgroups, 'Col1' as Col, 1 as value from dual union select 'Group 2' as Groups, 'Subgroup2' as Subgroups, 'Col2' as Col, 2 as value from dual union select 'Group 2' as Groups, 'Subgroup2' as Subgroups, 'Col3' as Col, 4 as value from dual union select 'Group 2' as Groups, 'Subgroup3' as Subgroups, 'Col3' as Col, 1 as value from dual
Below is a view of the same report with the fix :
Feel free to test, edit, correct or ignore if what I did is wrong and contact me if needed.
Regards