The 2 tables in question:
INV
Expense
The 3 fields in question:
INV_total,
EXP_total,
TAX_total
I need a calculation in a report that shows the difference between the 3 fields, a bit like:
INV_total - TAX_total + EXP_total
However for some reason this relatively simple idea eludes me (certainly in terms of execution :) )
Any help would be appreciated.
I'm relatively new to FMP.
Be... Gentle...
There are many possible answers, depending on what exactly you need and for what for purpose. It's unlikely that you would want to total all invoices and all expenses from all times since the beginning of your solution..
Let's say you want to do this calculation for a specific year. You could have a script find the invoices of the given year, place the invoice and tax totals in variables (using summary fields to get them), move to the expenses table and do the same.
Another way would be to use a third table and get the totals through a relationship based on a date range.
Added:
Here's an expansion of the first option, using a script to get the total of expenses.
These are the fields used in the script:
Expenses:
Date (Date)
Amount (Number)
sTotalAmount (Summary, Total of Amount)
Invoices:
Date (Date)
gTotalExpenses (Number, Global)
The script itself would look something like this (here, we are producing a report for the current year):
Enter Find Mode []
Go to Layout [ Expenses ]
Set Field [ Expenses::Date ; Year ( Get (CurrentDate) ) ]
Perform Find []
Set Field [ Invoices::gTotalExpenses ; Expenses::sTotalAmount ]
Enter Find Mode []
Go to Layout [ Invoices ]
Set Field [ Expenses::Date ; Year ( Get (CurrentDate) ) ]
Perform Find []
Sort Records []
At the end of this script, you should see your report with the global gTotalExpenses field containing the total amount of expenses for the current year.
On a long shot I'm going to assume that the expenses relate to an invoice in this case. So to do this calculation you will be best to use some relational database skills.
Give your invoice a unique ID, the best way to do this is add a field called InvoiceID which is a unique serial number. For this example let's assume you have an invoice with an InvoiceID of 123
Add a field called InvoiceID to your Expense table. Each expense that relates to invoice with InvoiceID of 123 will need InvoiceID set to 123.
Go to the relationship graph and link InvoiceID in your invoice table to InvoiceID in your expenses table drag and drop InvoiceID in the Invoice table to InvoiceID in the expense table.
In the invoice table create a calculation field which is INVTotal - TAXTotal + sum( Expense::EXP_total )
Related
I have a list of customer IDs and calculated an amount owing based on 2 columns (accounts receivable customer). As a customer might appear multiple times in the table, I calculate:
sumOver
(
max
(
{unlock_price} - {total_paid}),
[{unit_number}]
)
Based on how long a customer is owing the amount they are assigned to a class (PAR class).
ifelse ( {days_to_cutoff}<=6, "PAR 0-6", {days_to_cutoff}<=14, "PAR 7-14", {days_to_cutoff}<=30, "PAR 15-30", {days_to_cutoff}<=60, "PAR 30-60", {days_to_cutoff}>60, "PAR>60", "Current")
Now, I can visualise class and individual accounts receivable, see screenshot. What I actually want to get to is a total (SUM) of accounts receivable per class in a new calculated field or, ideally, combining all steps in one.
enter image description here
Whatever I tried results in QS complaining that I am trying to nest aggregations and cant do that.
sumOver ( sum ( {accounts_receivable_customer}), [{unit_number}], [{PAR_class}] )
What I am trying to achieve is to get a count of people employed in a particular period.
I have 3 variables:
Employee ID (integer)
Hire date (date)
Termination date (date or null)
Example
the formula I am looking for is something like
if termination_date is null
then
count employee_ID in
dates between Hire_date and max of either hire_date or termination_date
else
count employee ID in
dates between hire_date and termination_date
This aims to show the dynamic of staff level over the time.
I am new to Tableau, not sure how to even start with it. Any suggestions welcome.
This problem will be simpler if you reshape your data to have the following three columns
Employee ID
Date
Action. (where action takes on the values of ‘Hire’ or ‘Terminate’).
Each data row represents one change in status for an employees. If an employee had a termination date, they will have two records in this new format, otherwise just one record showing the hiring date.
You can reshape your data by hand, or leave the original and use Tableau Prep or the Tableau data source page to reshape using a self Union and a few simple calculated fields.
Define a calculated field called Staffing_Change as
if Action=‘Hire’ then 1 else -1 end
Now you can plot the change in staff level over time by putting exact date on columns and sum(Staffing_Change) on Rows. You can use a quick Table calc, Running Sum, to see the net staffing level. For line mark types, I’d use a step style by pressing on the path button on the Marks card. Otherwise, the chart can give the impression of fractional number of employees.
I'm creating a data entry form in Access where sales people can select a product, then enter a quantity for that product in each of 12 columns representing the next twelve months. For a given project, there may be up to ten products, so each product will be on a separate row.
Tables:
Project - fields ProjectID, ProjectName, City, SalespersonID, StartDate
ProjectDetail - fields ProjectDetailID, ProjectID, ProductID, Date, Quantity
Product - fields ProductID, ProductName
Salesman - fields SalespersonID, SalespersonName
Currently I have the Project form with the simple project header information, and I want the ProjectDetail information to be a subform, of course. But - when I used a query to give me "buckets" of Quantity for Month0 (the current month), Month1, Month2, etc., I found that I can't enter data into the form because the fields are based on an expression.
What's the best way to handle this? Thanks in advance!
If each ProjectDetail entry will have multiple sets of Date and Quantity, it might be wise to pull those out into a separate table with a one-to-many relationship to ProjectDetailID, especially if you anticipate the number of date/quantity pairs could change from twelve. So, a ProjectDetailQuantity table would have fields ProjectDetailQuantityID, ProjectDetailID, Date, Quantity. On your form, you would have the Project main form, with a sub form to ProjectDetail and another subform to ProjectDetailQuantity.
I have spent several hours trying to google my issue with no luck. I was wondering if anyone here would know how to do this.
I have 2 separate unrelated tables:
The first table has bank deposits(all deposits for a specific day) with the amounts example:
1/4/16 $10
1/4/16 $20
1/5/16 $15
1/5/16 $25
The second table has transactions from my billing software example:
1/4/16 $5
1/4/16 $12
1/4/16 $17
1/5/16 $22
1/5/16 $2
1/5/16 $4
I need to create a report, so that I can pull the sum for each day-
1/4/16 - first table sum: $30 - second table sum: $34
1/5/16 - first table sum: $40 - second table sum: $28
Is this possible? If so, how can I do this. I can get the sums for each table separately by using a group on the specific date field but I can not figure out how to do them both at the same time.
I you don't want to do much on database then create two sub-reports
Group data on date for both reports(Suppress details and header if you don't need them).
In both report Place Group name then First/Second table sum then Grand total Summary for your amount field.
Place both reports in front of each other and align them base line.
This will hopefully work for you if min date in both tables is same.
If min date is different then you can create a view or stored procedure to join data and just group it on date.
You can link both the tables using joins on date column and just group by date and take summary in group footer
Edit.......
I assume your last record will be duplicated so use running total.
Create a new running total
First select the field to summarize.
Second evaluate select radio button on every record
Third reset...select on change of your calculated field.
Suppose if you are summarizing amount field then
Filed to summarize: select amount
Evaluate: select for every record
Reset: on change of field amount
I am trying to create a chart (bar or line) in crystal from one table in my database (Sage CRM).
The records are as follows
CustomerId Date Invoice Amount
1234 3/4/2013 Cust Invoice 3322.00
1234 3/4/2013 Payment 2445.00
1234 4/5/2013 A/c transaction 322.00
1234 5/6/2013 interest 32.00
1234 6/6/2013 payment 643.00
So I would like to have a report that meets the following criteria
Only records for the last 12 months grouped in month
Only invoice types of payment, invoice and interest
A moving balance that calculates all the invoice amounts ie
(when displaying the information for July 2012, the moving balance will be the total of all invoices prior to this date.
Without this field I can create the chart no problem using select expert but I am not sure now what to do)
Should I use a cross tab? if so how will I do the selection to only show the invoices I want and the the date range I want?
After spending almost a week on this problem, with a lot of help from an expert I have finally got a solution.
In order to create a amount that is the sum of all records for a company, month and invoice type since the beginning of time, while only displaying records for the last year, I have created a SQL command
Select
//All of the fields for the report,
movingBalance.Amount
from myInvoiceTable as mit
<join to any other tables for the report>
left join (
select customerID, sum(amount) as Amount
from myInvoiceTable
where Record_Type in ('Payment', 'Invoice','Interest')
and Date < {?Report Start Date}
group by customerID) movingBalance
on mit.customerID = movingBalance.customerID
where mit.RecordType in ('Payment', 'Invoice','Interest')
and mit.Date >= {?Report Start Date}
and mit.Date <= {?Report End Date}
There are a couple of tricks to using commands:
For performance reasons you generally want to include ALL of the data for the report in a single command. Avoid joining multiple commands or joining one or more tables to a command.
Filter the data in the command, NOT in the Select Expert in the report.
Create any parameters in the Command Editor, not in the main report. Parameters created in the report won't work in the Command Editor.
This has done the trick.
Create Date Parameters in the report to filter out the records at the time of fetching now when you run the report you have left with the data you need.
Now you can manuplate the data inside report using formula fields.
Accoding to me writing stored procedures is a bit hectic task as you can manuplate the data inside the report. I don't have any intentions to disrespect anyone opinions but frankly its my opinion.
In that case Rachsherry I would recommend the following.
For criteria parts 1 & 2 I think instead of using stored procs, it may be easier for you to use a formula.
For invoices right click the invoice field, then "Format Field" in the common tab next to the Suppress option there is a formula button, enter the following...
IF {YourInvoiceField} IN ["Payment", "Invoice", "Interest] THEN FALSE ELSE TRUE
For your date requirement you need to use a selection formula... The code for that should look something like this
{YourDateHere} > DateAdd ("yyyy", -1, CurrentDate) AND {YourDateHere} < CurrentDate
The above code basically looks at dates between the day the report is run, and exactly a year before.
For your moving balance, you should be able to achive that with the guide here
Edit - An alternative to this is to use parameter fields (Which I don't personally like) it just means having to input the parameters every time the report is refreshed, they are self explanatory but you can find a guide here