The Fast Reports builder includes a "sum" checkbox for each field. I need to SUM some transaction totals, but for each Customer as well as total.
It does not work to create a group header and footer for each customer, then to clone the report "Sum" object and move the clone to the Customer footer.
I'd also like to report a Count of the number of transactions for each customer.
Is there a way to do these things in Reports?
Thank you!
Mike
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Adding COUNTs and SUMs to groups
Re: Adding COUNTs and SUMs to groups
Mike,
Good question.
Get the latest from Github first, but I have just added this to the Wiki...
http://wiki.nubuilder.net/nubuilderfort ... #Functions
You can use sum() or average(). - I will get to adding count() soon but in the meantime...
To simulate count() you will need to create a field for each record with the value of 1.
I would do it in a Procedure, rather than trying to make changes in the SQL Builder.
(Because if you try to manually change the SQL, the SQL Builder creates, it will get written over as soon as you do anything like drag a table.)
The Procedure could look like this...
Then you can do something like this...
Which will give you this...
ps. I hope no cricket tragic gets upset at me, I made up this grouping of captains.
Steven
Good question.
Get the latest from Github first, but I have just added this to the Wiki...
http://wiki.nubuilder.net/nubuilderfort ... #Functions
You can use sum() or average(). - I will get to adding count() soon but in the meantime...
To simulate count() you will need to create a field for each record with the value of 1.
I would do it in a Procedure, rather than trying to make changes in the SQL Builder.
(Because if you try to manually change the SQL, the SQL Builder creates, it will get written over as soon as you do anything like drag a table.)
The Procedure could look like this...
Code: Select all
$s = "
SELECT
sta_last_name,
sta_initials,
sta_games,
sta_runs,
sta_captain,
CONCAT(sta_last_name, ',', sta_initials) AS full_name,
1 AS player
FROM
stats
";
nuRunQuery("CREATE TABLE #TABLE_ID# $s");
Which will give you this...
ps. I hope no cricket tragic gets upset at me, I made up this grouping of captains.
Steven
You do not have the required permissions to view the files attached to this post.
-
- Posts: 14
- Joined: Mon Jan 15, 2018 7:53 pm
Re: Adding COUNTs and SUMs to groups
Steven,
First off: thank you for being so responsive to forum posts and so quick to implement suggestions and fixes!
What would be the most typical way to run this procedure before pulling the report? I can imagine running the procedure manually then running the report, but where does the table name come for nuRunQuery("CREATE TABLE #TABLE_ID# $s");?
Thank you!
Mike
First off: thank you for being so responsive to forum posts and so quick to implement suggestions and fixes!
What would be the most typical way to run this procedure before pulling the report? I can imagine running the procedure manually then running the report, but where does the table name come for nuRunQuery("CREATE TABLE #TABLE_ID# $s");?
Thank you!
Mike
Re: Adding COUNTs and SUMs to groups
Mike,
I've just updated the wiki, let me know me if this answers your question.
http://wiki.nubuilder.net/nubuilderfort ... orts#Table
Steven
I've just updated the wiki, let me know me if this answers your question.
http://wiki.nubuilder.net/nubuilderfort ... orts#Table
Steven
-
- Posts: 14
- Joined: Mon Jan 15, 2018 7:53 pm
Re: Adding COUNTs and SUMs to groups
I almost understand, I think... : )
So, if I create a procedure to create a temp table-- how do I base a report on that temporary table? Would I somehow have to create the temp table manually if i wanted to do a Fast Report?
How could I have multiple reports with different procedure-generated SQL statements?
Thank you for your patience and support!
Mike
So, if I create a procedure to create a temp table-- how do I base a report on that temporary table? Would I somehow have to create the temp table manually if i wanted to do a Fast Report?
How could I have multiple reports with different procedure-generated SQL statements?
Thank you for your patience and support!
Mike
Re: Adding COUNTs and SUMs to groups
Mike,
You said...
I'm not sure what you meant here but I had a go at explaining what I thought you meant.
Which you can use on as many reports as you like.
BTW Procedures will only appear in this list if they contain the string #TABLE_ID#.
Steven
You said...
Only if what you want to you display is more complicated than a single table (nuTABLE) and more complicated than a SELECT Query built by the SQL Builder (nuSQL).Would I somehow have to create the temp table manually if i wanted to do a Fast Report?
I'm not sure what you meant here but I had a go at explaining what I thought you meant.
Each Report requires a Table, which could be a Procedure (or nuTable or nuSQL).How could I have multiple reports with different procedure-generated SQL statements?
Which you can use on as many reports as you like.
BTW Procedures will only appear in this list if they contain the string #TABLE_ID#.
Steven
You do not have the required permissions to view the files attached to this post.
-
- Posts: 14
- Joined: Mon Jan 15, 2018 7:53 pm
Re: Adding COUNTs and SUMs to groups
Ahh-- now I understand: what I was missing was that #TABLE_ID# is "filled in" as the name the procedure given... Clear as day now that I see it... : )
So, am now updating my nb install with the newest git pull, then will head off to exploit my new understanding... : )
Thank you,
Mike
So, am now updating my nb install with the newest git pull, then will head off to exploit my new understanding... : )
Thank you,
Mike