Beruflich Dokumente
Kultur Dokumente
The date criteria enables you to extract data within a particular time period or before/after a certain
date as explained in this post…
Work Scenario
You are analysing the inventory data of your company and you want to know the following details:
Transaction Date – This field indicates the date on which the inventory transaction took place.
Quantity – This field indicates the total quantity of inventory being handled.
Transaction Type – This field indicates whether the inventory was sold, purchased or whether it was
on-hold.
Before you start creating any query, it is always a good practice to go through the table and its fields
that you’ll be analysing and have a look at the type of the data that they are holding.
In the above mentioned table “Inventory Transaction”, though the [Transaction Modified Date]
appears to be of the format mm/dd/yyyy, it is actually of the format mm/dd/yyyy hh:mm:ss
AM/PM.
Now, since you want to know the total inventory sold on a particular date, the time component is
irrelevant to your analysis. So, you will have to disregard the time by using the following functions:
format(“[]”, “mm/dd/yyyy”). But the output will be a a string of the format “mm/dd/yyyy” and you
need a date format.
Hence you’ll further use the cdate function over the format function:
cdate( format(“[]”, “mm/dd/yyyy”))
So, lets create a new query, to get the desired result as explained above:
On running this query, you get the following output:
Now that you have the dataset in the desired format, you can start working on the scenarios:
Scenario 1
In this scenario, you know outright that you need the result for one specific date only.
1. So, from the from the given dataset, you might want to filter the inventory transactions of that
particular date. (You might see the benefit of this step if you are dealing with thousands of records of
inventory transactions across hundreds of different dates.)
2. Then you group all the transactions on the required date (03/22/2006 in this case) and apply a dsum()
function to sum the field [Quantity] based on the criteria of date as well as transaction type (i.e.
inventory that was sold).
The criteria for DSUM() function will be written as follows:
Scenario 2
In order to find the total quantities across all the dates, you’ll provide a direct reference to the field
[Mdate] containing the date values while constructing the DSUM() function. The criteria in the
dsum() function will be written as follows:
You’ll construct the query exactly the same way you did in scenario 1 except that in this scenario you
would be referencing to the field instead of specifying a direct value:
In this way, you can get the desired result as required in scenario 2.
Summary
So, you have seen how a DSUM() function can be created and more importantly how a criteria can
be constructed based on the following three data types:
Also, in this post you have learnt the following two functions: