Am I missing something? Report Format "Group By" not like SQL

192 views
Skip to first unread message

Andy Conn

unread,
Feb 26, 2017, 7:34:55 PM2/26/17
to iDempiere
I have been enjoying playing with Accounting Fact Details report and been experimenting with a variety of reporting summaries. We have a large number of transactions to sort through so it is best to view the reports in summary mode. But then, I noticed that "Group By" fields do not summarize unless that group field value changes. This is not like SQL which would summarize each group if it OR a higher level group changed.

Consider the scenario: I'd like to show a summary of accounting debits and credits transactions by trxdate, table, recordid & account. If this were SQL I'd say

select trxdate, table, recordid, account, sum(debit), sum(credit) from myrv_fact_act group by trxdate, table, recordid, account

This query would return exactly what I want. In contrast, the Accounting Fact Details will only show me account summaries when it changes - regardless of whether recordid or any other higher level group by fields change. Therefore, if I have a series of transactions with different trxdate, tables, recordids that all hit the same account, I don't see the account being hit.

Am I missing something? This seems like an obvious problem with reporting.

Thanks,
Andy




Carlos Antonio Ruiz Gomez

unread,
Feb 27, 2017, 4:14:48 AM2/27/17
to idem...@googlegroups.com
Too little information.


El 27/02/17 a las 01:34, Andy Conn escribió:

Andy Conn

unread,
Feb 27, 2017, 10:52:25 AM2/27/17
to iDempiere

Does this help? These examples show output in summary mode. You can see I am sorting and grouping by trx date, table, recordid & account. The expected output shows I only get an account group total when the account changes. Instead, I would expect to see an account group total every time the recordid group changes as well (like you would see in SQL):

Carlos Antonio Ruiz Gomez

unread,
Feb 27, 2017, 11:09:01 AM2/27/17
to idem...@googlegroups.com
You can try setting all order columns as grouping - I think there is a mistake there ordering first by AcctDate and not grouping by it.

Also you can try showing the columns in the report.

Regards,

Carlos Ruiz


El 27/02/17 a las 16:52, Andy Conn escribió:

Does this help? These examples show output in summary mode. You can see I am sorting and grouping by trx date, table, recordid & account. The expected output shows I only get an account group total when the account changes. Instead, I would expect to see an account group total every time the recordid group changes as well (like you would see in SQL):


On Monday, February 27, 2017 at 4:14:48 AM UTC-5, Carlos Antonio Ruiz Gómez wrote:
Too little information.


El 27/02/17 a las 01:34, Andy Conn escribió:
I have been enjoying playing with Accounting Fact Details report and been experimenting with a variety of reporting summaries. We have a large number of transactions to sort through so it is best to view the reports in summary mode. But then, I noticed that "Group By" fields do not summarize unless that group field value changes. This is not like SQL which would summarize each group if it OR a higher level group changed.

Consider the scenario: I'd like to show a summary of accounting debits and credits transactions by trxdate, table, recordid & account. If this were SQL I'd say

select trxdate, table, recordid, account, sum(debit), sum(credit) from myrv_fact_act group by trxdate, table, recordid, account

This query would return exactly what I want. In contrast, the Accounting Fact Details will only show me account summaries when it changes - regardless of whether recordid or any other higher level group by fields change. Therefore, if I have a series of transactions with different trxdate, tables, recordids that all hit the same account, I don't see the account being hit.

Am I missing something? This seems like an obvious problem with reporting.

Thanks,
Andy

--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/19362941-0d44-42f4-91e8-23a2cfb31ade%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Andy Conn

unread,
Feb 27, 2017, 11:25:11 AM2/27/17
to iDempiere
Adding AcctDate as a Group By field does not have any additional impact.

I do not know what you mean by "Showing the Columns"; do you mean not summarizing? In this case, summarizing is very important due to the large number of detail records.

Hiep Lq

unread,
Feb 27, 2017, 8:37:54 PM2/27/17
to Mohemmed Bilal Ilyas
can you temp remove "*date" column out of group by and group list.
date is order by full value (minute, second, milliseconds) but break group just by display value (maybe just to day depend your report)

To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/1e290991-8078-4e6c-a8c6-adbf4a9df55e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Lê Quý Hiệp
Email: hie...@hasuvimex.vn
Skype: admin.hasuvimex

Company: Thanh Hoa Fishery Import - Export J.s.c  (HasuvimexDL 47
Add: Lot E, Le Mon Industrial Zone, Thanh Hoa, Vietnam

Hiep Lq

unread,
Feb 27, 2017, 8:38:36 PM2/27/17
to Mohemmed Bilal Ilyas
"out of group by and group list." i mean order by and group list

Andy Conn

unread,
Feb 27, 2017, 8:50:49 PM2/27/17
to iDempiere
I am seeing no change in the report when I remove Acct Date. 

Here is a more simple explanation of what I see:

REPORT FORMAT
Order by:    Account, Trx Date
Group By: Account, Trx Date
Sum:         Accounted


DATA
Account    Trx Date   Accounted
11100       2/22/2002     50.00
11100       2/22/2002     98.00
11200       2/22/2002     -100.00
11200       2/22/2002     100.00
11300       8/10/2002     100.00

I should expect to see (summary only):

                 2/22/2002    148.00
11100                           
148.00
                 2/22/2002    100.00
11200                           100.00
                 8/10/2002    -100.00
11300                           -100.00

but instead I see


11100                           
148.00
                 2/22/2002    248.00
11200                           100.00
                 8/10/2002    -100.00
11300                           -100.00
--
Lê Quý Hiệp
Email: hie...@hasuvimex.vn
Skype: admin.hasuvimex

Company: Thanh Hoa Fishery Import - Export J.s.c  (HasuvimexDL 47
Add: Lot E, Le Mon Industrial Zone, Thanh Hoa, Vietnam

Andy Conn

unread,
Feb 27, 2017, 9:00:09 PM2/27/17
to iDempiere
Oops - corrected example:


I am seeing no change in the report when I remove Acct Date. 

Here is a more simple explanation of what I see:

REPORT FORMAT
Order by:    Account, Trx Date
Group By: Account, Trx Date
Sum:         Accounted


DATA
Account    Trx Date   Accounted
11100       2/22/2002       50.00
11100       2/22/2002       98.00
11200       2/22/2002    -100.00
11200       2/22/2002     100.00
11300       8/10/2002     100.00

I should expect to see (summary only):

                 2/22/2002    148.00
11100                           
148.00
                 2/22/2002       0.00
11200                              0.00
                 8/10/2002    100.00
11300                           100.00

but instead I see


11100                             
148.00
                 2/22/2002     148.00
11200                                0.00
                 8/10/2002     100.00
11300                            100.00

Hiep Lq

unread,
Feb 27, 2017, 10:41:51 PM2/27/17
to Mohemmed Bilal Ilyas
I see each group you have two line one for date and one for trx_date and one for account.
it's default behavior or by your setup? i'm not fan of default report.

(*) account 11100 isn't have date line, it miss from report or just by mistake when copy/paste

by your latest example, 
  group is corrected, you have three group, 
  sum is almost corrected
  just one line of trx_date is incorrect other things is work well

data for date 2/22/2002 is special, it don't change on account 11100, 11200

can you setup it on demo to easy collaborate?

you also can check sql query to get data of report  by debug at line "pd.setSQL(finalSQL.toString());" class DataEngine

To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/80059ff5-8cbe-4114-9942-d347ac108a9f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Andy Conn

unread,
Feb 27, 2017, 11:24:58 PM2/27/17
to iDempiere
OK - I set it up in test.idempiere.org

1) Choose:
* Print Format: Accounting Fact Details - ANDYC
* Saved Parameters: ANDYC-1
2) See at bottom of report a summary  for 21190 and 51400 for each Record ID change (image1)

3) Now re-run choosing:
* Print Format: Accouting Fact Details - ANDYC
* Print Parameters: ANDYC-2
4) Since the I chose a single account, it only shows entry for the account at the bottom (image2) instead for each Record ID change



Hiep Lq

unread,
Feb 28, 2017, 4:23:48 AM2/28/17
to Mohemmed Bilal Ilyas
it look normal.
record is same like you run sql with group clause.
but you have a extra sum line for each time one column on group is changed.

4) Since the I chose a single account, it only shows entry for the account at the bottom (image2) instead for each Record ID change
i see, 

it don't print out duplicate value is normal, just don't know why have line "51400-Inventory Clearing Σ"  
maybe a fan of default report can explain about it

To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/2dbdcc21-a035-4ea3-b920-a8896fd9b6f4%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

anton....@fildan.com

unread,
Mar 31, 2017, 7:51:31 AM3/31/17
to iDempiere
Hallo,

I can confirm Andy's observation.
Some time ago I created a report on the FACT table grouping by account and activity
Expecting a sub-balance for each activity and a balance for each account
Every time the last activity of the previous account was equal to the first activity of the next account,
the activity balance was made across two different accounts.

Not only in SQL but also using an Excel Pivot Table one would not expect that behavior.
I considered it an error. - that time I found a way to use financial statement reporting around this problem.

KR
Anton Fildan

Luis Amesty

unread,
Apr 2, 2017, 1:57:18 PM4/2/17
to iDempiere

Hi Andy
 
when i want to disconect Groups on Querys i use:
WITH Querys
I put my first GROUP BY on with and second GROUP BY on final SELECT.
You may have samples on Stackoverflow, i give you one.

Example:
WITH regional_sales AS (
        SELECT region, SUM(amount) AS total_sales
        FROM orders
        GROUP BY region
     ), top_regions AS (
        SELECT region
        FROM regional_sales
        WHERE total_sales > (SELECT SUM(total_sales)/10 FROM regional_sales)
     )
SELECT region,
       product,
       SUM(quantity) AS product_units,
       SUM(amount) AS product_sales
FROM orders
WHERE region IN (SELECT region FROM top_regions)
GROUP BY region, product;

Luis Amesty

unread,
Apr 2, 2017, 2:02:25 PM4/2/17
to iDempiere

Another way is making a JOIN with a SELECT with GROUP BY
Complementing with UNION.

Look at Query Sample for Trial Balance.

TrialBalance.sql

Steven Sackett

unread,
Apr 2, 2017, 11:19:25 PM4/2/17
to iDempiere
Hi,
We also saw the problem described by Anton.
Paul made the following change to fix.


regards..

Carlos Antonio Ruiz Gómez

unread,
Apr 3, 2017, 4:15:52 PM4/3/17
to iDempiere

Andy Conn

unread,
Apr 3, 2017, 4:26:49 PM4/3/17
to idem...@googlegroups.com
Awesome - thanks Carlos!

--
You received this message because you are subscribed to a topic in the Google Groups "iDempiere" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/idempiere/IElG9CIhG50/unsubscribe.
To unsubscribe from this group and all its topics, send an email to idempiere+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/f3290377-7c35-41e2-822a-8b1dd018fe6f%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages