Create a chart using the records of certain type grouped by month, with a moving balance - crystal-reports

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

Related

Financial formulation in Crystal Reports

I need help with creating a trial balance report for a specific tenure, from beginning of fiscal year to a selected period. I need this in Crystal Reports.
I am unable to formulate how can I get debit and credit amounts totalling from beginning of the fiscal year till the end of selected period (not YTD).
For example, I want to get a trial balance report till period 6 (June), I am able to get the balance at the end of period 6, but unable to formulate total credits and total debits for selected number of periods/months. Instead, it is either debit/credit amounts for June or it's for total debit/credits till date.
Can anyone help me please?
Create a formula that returns, for each record, it's dollar amount if it's within the target date range, otherwise, zero.
Sum that formula to get the total for that time period.
I'm a user of the DelmiaWorks/IQMS ERP solution as well. IQMS uses a stored procedure to populate a database table named "C_TRIAL_BALANCE_AS_OF". When you publish a report into IQMS, there is a field named "Execute Before Print" on the Edit Report Definition window that opens when edit a report. To run this stored procedure in conjunction with another report, you will want to choose "POP_C_TRIAL_BALANCE_AS_OF" in the drop-down box control for this field. This will ensure the procedure is run prior to the report so you have the account balances you need as of a specified date. When the report is executed, IQMS will present the user with a Date Picker for the As Of Date. Almost all of the data you need to do a Trial Balance report can be found on this calculated table. The only joins needed should be "V_GLYEAR_PERIODS", "V_GLACCT", and "EPLANT".
There is a built-in report that may do what you want already though. If you begin the Trial Balance module and then click "Reports" > "Print" to bring up the list of all reports, then look for one named "Trial Balance As Of". Even if this report is lacking some information you need, it will likely be much easier to edit this existing report than it would be to create one from scratch.
If you don't have this built-in report, you may be able to get a copy of the RPT file from their support department. As long as you have the Trial Balance module, you should have this report. Its a standard report that is included in every version of IQMS I've worked with. However, my experience is limited to the 15.3 and 2020 versions.

Crystal reports - Can't filter on custom formula number field

Crystal reports don't let me use a custom count formula field to filter which transactions to show in a manager report.
I'm creating a Crystal report that team leaders are supposed to take out to see on how many occasions their employees have reported in sick. A record is only supposed to show if that person has reported in sick 6 or more times the last 12 months.
The report shows a record (a page) for each employee belonging to the managers organisational unit. Below the employee information is a subreport where I show the transactions from the salary/time system. Using select expert, I have filtered out the transactions that is supposed to show. I have then created a database field that count which day was 12 months back from today, and filtered so that only the transactions falling into this period shows.
My last problem is that I only want to show the record that has a minimum of 6 such transactions during the period. I created a formula field named #Antal ("amount" in Swedish) that simply counts the distinct number of dates in the "from"-date for the salary transactions I'm showing (since a change of law 2019-01-01 we needed to create a new transaction type, so some of the occasions after 2019 may have two transactions referring to one sick leave, thus I'm counting the first day of the period instead), DistinctCount ({P_LSTAT.P_SXXX06})
Now, the subreport has a new column with Antal (amount) that counts the amount of the desired salary transaction. I then try to use the selection formula to only show records where {#Antal} >= 6 but I get the following error:
This formula cannot be used because it must be evaluated later
Is there any other (better) way of doing this, or am I simply missing something?
For your selection based on {#Antal} >= 6 you need to use the group selection formula, not the record selection formula. Record selection is used to select records which meet the criteria before reading in the data. Group selection is used to filter out entire groups of records based on summarised values, after the records have been read in and the summaries calculated - which sounds like exactly what you need here.
The value of a Formula Field is out of scope when the Select Expert is evaluated.
There is no process for calculating the value of a Formula Field before it is printed within the section of the report it is placed. The Select Expert is evaluated prior to any section of the report being printed, so at this time all Formula Fields are effectively Nothing.

Crystal Reports Sum per date from 2 different reports

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

Crystal Reports Filter by Most Recent Date of Field

I have a report I am creating through an ODBC connection. The report includes several invoices, where each invoice has several products. There is also a table which contains all the historical price changes for each product (field: unit-price). Currently there are duplicate product records being pulled, one for each time there was a price change. Therefore, I need to filter my data so that only the most recent unit-price is shown (date field: effective-date). How can I do this via the "Select Expert?"
In short, show the product's unit-price for the most recent effective-date.
Thank you!
You'll need to create a sql-expression field to get the most-recent effective date, then use this field in the record-selection formula.
// {%MAX_EFFECTIVE_DATE}
// most-likely you'll need to alias the table in the main report for this to work
(
SELECT Max(effective_date)
FROM price_history
WHERE product_id = price_history_alias.product_id
)
Record-selection formula:
{price_history_alias.effective_date}={%MAX_EFFECTIVE_DATE}
Instead of doing it in select expert. group by effective date and set the ordering as Descending.

Crystal Reports: get access to linked elements in selection formula

I'm making a report using Crystal Reports 2008 and Peachtree database. Report should display customers who didn't place orders in a last 30 days. I already figured out how to link two tables in CR with left outer join. But I wasn't able to find how that linking can be used in formulas, such as selection formula. What I am trying to achieve is to get date of last placed order for current customer and use this information to determine if customer should be displayed or not.
What is the right approach to solving this problem?
Assuming your data is setup properly and adding 'customer' and 'last order date' to the details section shows you everything, then you can just add conditional formatting formula for the suppress property of the section when 'data date - last order date < 30', leaving you only showing records where last order date is more than 30 days.