Access Report - Can't add a sum for a calculated currency column - report

I've generated a simple access report that is used for purchasing.
Basically, there are two tables, one for purchase orders, and one for the items on the purchase orders.
For the items on an order, I store the item details, quantity ordered, quantity delivered, and price per unit. (plus a few other fields which aren't relevant in the context of this question).
I'm generating a report to list all outstanding items still on order, and the report has a calculated field showing the outstanding quantity * cost per item. This works perfectly fine.
What I'm struggling with, is showing a sum of this calculated field (i.e. a total cost of all outstanding items), but when I try to add a total to the column, it only gives me the option of adding an item count for the column. The column is a 'Currency' field.
What might I be doing wrong, or am I expecting too much from access?

Resolved. I created the only option that the GUI would allow (item count), then modified the query from:
=Count(*)
to
=Sum([Quantity]*[Cost])
Works perfectly.

Related

SQLiteStudio automatically insert value

I have a database created with SQLiteStudio that has a products table with two columns, item and price. It also has a sales table with an item column that is linked to the item column in products. I'd like the sales table to also have a price column, whose value is automatically set to that of the products.price row corresponding to the value selected from the products.item column. How would I define the sales.price column so that this value is automatically set?
Also, the prices in the products table may be changed from time to time, but the price listed in any existing sales records must not be updated when this is done.
SQLite has generated columns (also called expression columns) that are found in other DBMSes. But you'll need a fairly recent version of SQLite:
Generated column support was added with SQLite version 3.31.0
(2020-01-22). If an earlier version of SQLite attempts to read a
database file that contains a generated column in its schema, then
that earlier version will perceive the generated column syntax as an
error and will report that the database schema is corrupt.
Source: Generated Columns
You could simply build a view to augment your table a little bit.
You have mentioned that the prices will change over time and this is perfectly normal. So you have at least two design choices:
add an additional table to store price history, in that table you store product ID, price, start date and end date (as an example). Then you join it with the other tables. The effective price shall be determined based on the order date. That also means that the prices are to be stored in that table and not in products... you have to redesign your schema slightly.
the other option is to store the unit price of the product in the sales table as a historical value. This is the price that was in force when the sale was made.
One thing to consider: you may require more flexibility on pricing: it can depend on the client (different rates based on volume) and also on specific circumstances. The final price may be the result of numerous and complex calculations.

GA: Report with transactions doesn't show all of them

I have created a report with Data Studio taking values from GA and I have defined a table with several data like age, sex, hour, total users and transaccions.
At the end of the table it shows the total of transactions which are 8 and this data is correct. But If I seek this transactions in the table I only found 2.
Here you can see the table ordered by transactions and you can see how there is only 2.
And these are the sources of the data of the table:
Am I doing something wrong? How can I get the eight transactions in their own column?
Edit I:
The table are ordered descendent by the column "Transactions" (Transacciones) so all the transactions are showed in the first rows. In this case, we've got only 2 transactions.
In string 'Total' Data Studio shows Total not for your split, but just Total (Yes, it's strange). Test it in this way: create a new widget contains only 'Users' or 'Transactions'. You will see that number is the same as in your table in 'Total'.
You have 10 per page, change this view to match the total number of records. The reminder are likely on following pages

Crystal reports, get sum for specific reocrds

In Short:
I need to get a total for customer groups + the credits - the debits in a specific date range.
In Detail:
I'm creating an invoice report for customer orders. Each Customer belongs to a group, and I need to group the invoice by customer group so I can give a total amount owed for the customer group.
So the top Group in the report is customers.group_name with the total for the group in the group header.
The second group is orders.customer_id with the total for the customer in the group header.
I have 2 parameter for the date range of orders which I use in the select expert
I have another table for credits and debits for each group.
This are the fields for the CreditDebits Table
group_name
date_
type_ (this can be either "credit" or "debit")
amount
I've linked customers.group_name with CreditsDebits.group_name in the database expert.
I also use the date range parameters for this table
Do get the credits I created a formula called "credists" like so
if {Credits_Debits.type} = "credit" then sum({Credits_Debits.amount})
But when I drop this formula on the customers.group_name header, the formula shows up as empty and the total for the group gets messed up (it becomes triple of what it should be.
What am I doing wrong?
First check Does this field CreditsDebits.group_name consists of customer name? or any different name?
Place the formula if {Credits_Debits.type} = "credit" then sum({Credits_Debits.amount}) in footer but not in header and check.

How to get calculated value of grid fields in realEdit control?

I have created a tableA with fields ItemId, Quantity and Price(I have made the display method in tableA's method which returns the price of selected item). I dragged my display method in field groups and I'm using that field group in my form's grid
My question is how to calculate the total sum of selected item's prices and how to show the result in realEdit control?
I will assume you want the accumulated Quantity * Price for your lines.
The easiest way is to store the line amount field on table redundantly and compute it in the modifiedField method.
Then your total field could be a display method:
display Amount total()
{
return (select sum(LineAmount) from TableA where ...).LineAmount;
}
Other solutions are possible such as a computed view field, but this one is a simple no-brainer.
The standard table SalesLine uses this approach as well albeit for other reasons.
That said even simple solutions come to short, if you have thousands of lines, in this case consider caching the total (on entry) then updating manually in write and delete methods.

Query on use of aggregate functions over recursive groups in microsoft report designer

I have to point out that I'm fairly new to reporting outside of Microsoft Access, and new to the site, so please bear with me!
Stripped down to essential items, my data object has:
CategoryID, ParentCategoryID, TransactionID, TransactionDate, SplitID, CurrencyID and Value.
I don't think this is relevant, but just in case -
A Split has a Category and a Value, with one to many belonging to a Transaction.
Multiple Splits may exist for the same Category & Transaction with
different, or the same, Value (to support different combinations of the other data
items I haven't listed).
A Transaction has a TransactionDate and a CurrencyID, so all Splits
belonging to a Transaction are for the same Currency.
A Category belongs to a Category recursively.
A Split may be assigned a Category at any level in the recursive hierarchy and the crux of my problem is to report Transaction / Split detail under the appropriate Category heading, with a sub-total to include all those details AND the totals of all child Categories.
So, I have a Detail row group holding all the ancilliary data items that aren't relevant and a TransactionIDGroup row group on the same row. I then have a CategoryGroup row group based on CategoryID with a Parent of ParentCategoryID to handle the recursive nature of the data and a CurrencyIDGroup column group to handle the possible multiple currencies involved.
Also in the CategoryIDGroup row group is a total row with the Value cell holding an expression.
If I leave that expression as =Sum(Fields!AccountValue.Value), the report quite nicely totals the Value for each Currency column for all the details specifically in each Category (the default scope), so I thought I needed to make the Sum 'Recursive'. However, you don't seem able to specify the optional Recursive parameter without specifying the scope as well.
If I specify scope as CategoryIDGroup, I get all zero sub-totals. If I use CurrencyIDGroup I get each one being the same report total for the Currency. Anything else either gets me a build error or a combined-currency report total.
The other issue I have is that the recursive child Category groups are reported sequentially underneath the parent Category group (so, outside the header row, detail rows and total row, and not within the group. However, if I can get the total to reflect the children as well as the details at that level, I'd be happy enough, even though it wouldn't seem to add up until you realised what was going on.
What I have in mind is something like:
Category A
Transaction 1 10/02/2011 ...................... £100.00
---------------------- £14.50
Transaction 2 18/03/2011 ...................... $159.34
Category Ai
Transaction 3 18/06/2011 ---------------------- £295.60
Total Category Ai £295.60
Total Category A £410.10 $159.34*
But what I get is this:
Category A
Transaction 1 10/02/2011 ...................... £100.00
---------------------- £14.50
Transaction 2 18/03/2011 ...................... $159.34
Total Category A £114.50 $159.34*
Category Ai
Transaction 3 18/06/2011 ---------------------- £295.60
Total Category Ai £295.60
I guess the fundamental question is - am I asking the impossible? Do I need to take a different approach, perhaps with sub-reports for the details? I've wondered about including a Sum of the values of the child Categories within the data object at each Category level, but is there something simple I'm missing?
Any pointers in the right direction would be greatly appreciated after several days tearing my hair out :)
I have no idea whether there was something simple I missed, but resolved the issue to my satisfaction by including another property in the data object, being the sum of all child categories for each currency, and including a new row to print the sum of that field. Just in case someone else hits just the same question!

Resources