Sum specific data - eloquent

I Have this table for bills. In bills I have field call amount_left. Whenever I add a new record this field got update. Now I need to calculate outstanding but the problem is I have to sum only latest records of all individual property_id. How to do that?

Related

Crystal Reports Filtering and Organizing data

I am writing a small Crystal Report using 2 tables (TICKET,HISTORY,CUSTOMER) from a database I was given access to. I do not have access to modify the database tables to correct the issue and I am looking to see if this is possible.
The TICKET table is my main table and has a 1 to Many relation to HISTORY table.
The CUSTOMER table has 1 to Many relation to the TICKET table.
Inside the HISTORY table, there is column called Version. Every time a HISTORY entry is added on a TICKET, the Version number is written into this field, ie 21.4, 19.7, etc.
Ideally, the version would be better suited attached to the CUSTOMER table once the entry was added into the HISTORY table, but that change has not been made.
What I am trying to do with my report is group and display my results as follows:
Version Number
Customer Name
I can get this far, but the issue I am running into is, I only want to show the customer on their latest version number and suppress all previous records so I can get an accurate count of how many and which customers are on each version. Is this possible to do?
If you are allowed to create a VIEW in the database, create one that joins Ticket to History, groups on Ticket ID, and returns the Ticket ID and the Max of the Version.
In Crystal, you can then simply joint to that View.

Convert String Count into a Calculated Field

I am trying to turn a count of strings into a calculated field, but I am not able to use the drop down menu in the calculated field.
It is a little unclear what you are trying to do here.
If you are trying to count the number of unique membership IDs then you need to write a formula like CountD(Member ID). You will then have a measure that gives the total number of member IDs in the database.
If , on the other hand, you want to count the number of times a member appears in the database, you could use Count(Member ID). Then, when you drag the Member ID to a row, you can drag the new measure you have creates and get a table of the counts for each member.

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 including multiple records with queries

I have a database table named ORDERS that contains repair order data and invoice data. Each record has an ORDERTYPE (i.e. INVOICE or REPAIR) and all invoice records have a system-generated ORDERID that links them to the repair orders (called the REFORDERID).
I have a second database table called ORDERLN that contains all individual line items for the repair orders and invoices. I need to access this data selectively to retrieve sales and cost information.
I need to limit my selected report data by the INVOICE DATE, which is contained in the ORDERS table. I have been trying to limit the report's record selection by DATE and INVOICE TYPE but that restricts me to only working with INVOICE data. I need sales data, which is on the invoice and I can get this easily, but I also need cost data which is only on the repair order, hence my need to query that data as well.
I need a way to first restrict the invoice close date, then pull in the invoice data AND pull in the repair order data. The link to the repair order data must be made via the REFORDERID records.
Can anyone guide me either with record selection formulas or SQL queries?
Thanks,
John
As per your requirement and explanation.. below is my approach...
Link the ORDERS and ORDERLN tables in database expert.
To limit the data create 3 parameters Start Date, End Date and one parameter for Invoice type.
In record selection formula write below formula.
If you are picking the invoice date form ORDERS then
ORDERS.Invoice Date>={?Start Date} and ORDERS.Invoice Date<{?End Date} and
ORDERS.Invoice Type={?Invoice Type}
Above selection will pick the user required date and invoice type from database.
Now place the fields you need in the report design

Referencing first record in a group in crystal reports

In my report, in group footer, I want to add the sum on a column from all records in the group except the first one. How can I do that?
I tried Insert - Subtotal but it adds all records. If I can access the first record from each group, I can subtract it from the sum.
Let's say you're grouping your report by {Table.GroupID} and want to get the total per group, excluding the first record in the group, for {Table.NumericField}.
You can do this by creating a running total where:
Field to summarize: Table.NumericField; Type of summary: Sum
Set to evaluate with a formula: previous({Table.GroupID})={Table.GroupID}
Reset on change of group
The second step ensures that the group total is updated for every record except the first one in the group and can be read as "Only evaluate this running total when the previous record's GroupID is the same as the current record's GroupID.