profile loss statement report - vb.net

i want to make crystal report of profit and loss statement
i have a column of "vr_type" and there are 4 types in it "sale invoice", purchase invoice" now i want that put a 4 formula s where i select that "sum (vr_detail.debit) where vr_detail.vr_type} sale invoice it make Sum of al these types so kindly tell me what formula i should use to get the result
in simply i want sum of sale,sum of purchase,sum of expense
thanks

Crystal Reports doesn't have a sumif() function. You will need to create a formula field for each type of field that you want to summarize, then insert a Summarized field on the formula field.
For example, you could create a field named 'sales invoice'. The text of the formula would be:
if {vr_detail.vr_type}="sales invoice" then
{vr_detail.debit}
else
0
You would then select this field, then Insert | Summary...
You'll need to repeat this for each field.
** edit **
If you simply want subtotals by vr_type, follow these steps:
Insert a group on the {vr_detail.vr_type} field. This will add a group-header (GH) and group-footer (GF) section to the report.
Insert a summarized field on the {vr_detail.debit} and/or {vr_detail.credit} field.

Related

Sum Calculation for Tax

Can you please help me on Crystal Report, where I'm trying to create a formula.
Case:
I have 2 tables, Table1 has some columns (like ItemName, ItemPrice, TaxType, TaxRate).
Table2 has Items sold with columns (like ItemName, Qty, ItemPrice, ItemTotal).
I have also linked the column in crystal report for ItemName, so that they can fetch related data.
I am looking for a formula in crystal report that can sum up tax rate * item total where tax type= VAT and TaxType= GST
My formula structure will be like:
VATSum ({table1.taxrate}*{table2.totalamount}) where table1.taxtype= 'VAT'
GSTSum ({table1.taxrate}*{table2.totalamount}) where table1.taxtype= 'GST'
Please guide.
I would really appreciate any body's efforts to solve this problem.
In Group Expert you will want to begin by creating a Group on the {table1.taxtype} field. This will ensure all of your VAT and GST items sold are grouped together. If you have other taxtype values than VAT and GST you will need to decide how to handle those taxtypes. You use Select Expert to filter them out if they are not needed for the report, or do nothing and they will all appear within additional groups on the report by their taxtype values.
You will need to then create a formula field that can be used to calculate the tax for each item sold. The name of this formula will be referenced by other formula fields in the report, so I will call this formula field itemTax in this example. The formula for this field will be:
{table1.taxrate}*{table2.totalamount};
Place the itemTax formula field into the details section of the report.
From here you have 3 options on how to calculate the sum of itemTax. You may insert a Summary Field, a Running Total Field, or another Formula Field. Any of them will work for you, but I will continue with the Formula Field option.
Create another formula field and name it totalTaxByGroup. The formula for this field will be:
Sum({#itemTax}, {table1.taxtype});
Then place this formula field in the Group Footer section of the taxtype group.

get previous total from filtered amount in crystal report

I have created the following report in Crystal Report using VB.Net 2012. The OPENING BALANCE & NET TOTAL rows are not in my report but my question is there.
TR_ID | TR_DATE |DETAILS | EXPENSE | INCOME | BALANCE
OPENING BALANCE 0.00
1005 08/24/2015 CASH RTN 0.00 10,000.00 10,000.00
1013 08/25/2015 PURCHASE 3,500.00 0.00 6,500.00
1014 08/25/2015 DEPOSIT 5,000.00 0.00 1,500.00
1013 08/27/2015 SALES 0.00 4,000.00 5,500.00
NET TOTAL 5,500.00
I filtered the specific records within the date range of 08/25/2015 and 08/26/2015 & it works well. My question is how I get the previous balance (10000) of the specific date (08/25/2015) in "OPENING BALANCE" row and the total balance in "NET TOTAL" row?
As per the given datas above, the report shows the 4 records well excluding the rows of OPENING BALANCE & NET TOTAL. I want to add the OPENING BALANCE row to show the opening balance of every vendors' accounts when I open the report. And if I view the records of a particular customer within a date range, then OPENING BALANCE row should show the previous balance until the start date of the given date criteria. Ex: If I select records from 08/25/2015 to 08/26/2015 as per above datas, the report will show the two particular records (2nd & 3rd). But I want to show the previous balance 10,000 or the total amount which is above to the star date (08/25/2015) should be shown in the OPENING BALANCE row. And the sub total amount of this vendor's
should be shown in the last NET TOTAL row. So, pls help me, how the formulas will come & how to do.
Thank you
I expect your great help
Thank you
It´s not too much clear to me, but you may try to get the values directly from the report using a variable to do it.
With the report opened, you may entry in the CrystalReport option and select "Selection Expert - Saved Data".
You must create a formula using the "Formula Field" at left panel, and build it using the top 3 windows:
The first top window shows the fields of the table your report handles;
The middle top window show some built-in formulas
SO, you must
Go to formula field and create a new one;
Select the field at the top-left window you want to get (the Openning)
Drag-drop it into the main window (below the 3 top selections) and save it as a new variable
Add this variable into your report. This way, you may get this field for calculations in the same report.
Is it you need to do?
Sorry if I cannot understand exactly what you need.
Hugs!
UPDATE
You may have TOTAL creating a formula of SUM within report.
Click on the field EXPENSE (which appear in 3 rows) and select in menu: CRYSTAL REPORTS - INSERT - SUMMARY. It will create a field that must be positioned at the bottom (in the new Group will be created).
Do the same with INCOME field.
Create a FORMULA FIELD at the bottom to calculate the difference between both SUMARIES. You can name each of these summary fields (like IncSum and ExpSum) and put in that third field: IncSum-ExpSum. You may also put them as invisible.
Your final balance should be:
OldBalance (the parameter I point next lines)
+
Movement (the field that reflects IncSum-ExpSum)
To get the last/old Balance, you may have to get it from code as pass it as a PARAMETER. To do this, create a parameter in te report: see in the FIELD EXPLORER you have a choice of PARAMETER FIELD. AFter create it, use this code:
Dim MyCrystalReportt As New ReportDocument()
MyCrystalReportt.Load(Application.StartupPath & "\ReportSample.rpt\")
MyCrystalReportt.SetDatabaseLogon(UserID, Password, DataSource, InitialCatalog)
Dim myLogonInfo As New TableLogOnInfo()
Dim myTable As Table
For Each myTable In MyCrystalReportt.Database.Tables
myLogonInfo = myTable.LogOnInfo
myLogonInfo.ConnectionInfo.ServerName = DataSource
myLogonInfo.ConnectionInfo.DatabaseName = InitialCatalog
myLogonInfo.ConnectionInfo.UserID = UserID
myLogonInfo.ConnectionInfo.Password = Password
myTable.ApplyLogOnInfo(myLogonInfo)
Next
MyCrystalReportt.SetParameterValue("Data1", LastBalance.Value.ToString)
ReportsForm.CrystalReportViewer1.Reportsource = MyCrystalReport
ReportsForm.show
Notes:
You may have a form (ReportsForm) with a Crystal Control within (CrystalReportViewer1).
Datasource is the Server Name or IP
InitialCatalog is the Database (not the table!)
The ParameterValue MUST be a string - is numeric is required, convert it to number inside the Report. Use a temp_field to get it (see formulas of Crystal and you will find some to make this task).
I hope it can help you.
Good luck.

Making Excel report into SSRS with Pivot Tables

I am trying to create a SSRS report from an ad hoc script I have. I can get results but the user of the report requests certain pivots that I can not seem to correctly display the information.
Below is an export of the report from sql with the pivots added. I want each row to be grouped by the GRADE first, OD second, and ID third. The pivot is adjusted for the STOCK NUMBERs. Each row with matching grade,OD, and ID will have numerous stock numbers.
http://i.imgur.com/Bx3yMuX.png
This is the closest I have have came to displaying the information in SSRS.
http://i.imgur.com/hpajKmB.png
Is there anyway I can have the Stock numbers run across a single row instead of a row for each stock number?
I would create a Column Group based on Stock number. That will generate a column for each Stock number.
It was a little more tricky than I thought. Since I did not want the Stock Number to actually be a column header but to just list on each column corresponding to my group it was not an actual pivot and was why it was not working properly.
Basically to get it to work I had to use the LookUpSet+Join function in SSRS to list the stock numbers out. I was not required to list them out on different columns. Thank-you for your replies.
Here is the code I used in the column
=Join(LookupSet(Fields!grade.Value & Fields!od.Value & Fields!wall.Value & Fields!id.Value, Fields!grade.Value & Fields!od.Value & Fields!wall.Value & Fields!id.Value, RTrim(Fields!stock_number.Value), "FOC"), ", ")

SSRS Expression Sum Between Numbers

I am seeking assistance with creating a VB expression in SSRS that subtracts SUMS. I have a dataset that has accounts and corresponding money/amount values. I need help creating an expression that sums up the money/amount values from one group of the accounts in a specified range, and then subtracts it from the money/amount total of another range. Specifically:
(Sum(amt) where acct between 40000 and 49999) -
(Sum(amt) where (acct between 50000 and 59999) or (acct between 66000 and 69999)) -
(Sum(amt) where acct between 76000 and 79825) -
(Sum(amt) where acct between 89000 and 90399)
Really need help translating this SQL logic into a VB expression to be used for a textbox in SSRS. Any advice would be extremely helpful! Thanks!
textbox can only capture the first value of the dataset, so if you go to the expression builder for the textbox, you can see there are no fields from the dataset available. But, aggregate functions on dataset fields are available.
So you can create a calculated field to your dataset and add amount values to it with appropriate signs such that the sum of all the values in this calculated field represents your desired solution.
For example, add a new calculated field to your dataset. In the field source, add an appropriate expression like:
=IIF(Fields!acct.Value>=40000 AND Fields!acct.Value<=49999, CInt(Fields!amt.Value),
IIF( (Fields!acct.Value>=50000 AND Fields!acct.Value<=59999) OR
(Fields!acct.Value>=66000 AND Fields!acct.Value<=69999) OR
(Fields!acct.Value>=76000 AND Fields!acct.Value<=79825) OR
(Fields!acct.Value>=89000 AND Fields!acct.Value<=90399),
CInt(0 - Fields!amt.Value), CInt(0)
)
)
This keeps the values between 40000 and 49999 as they are. Makes all values needed to be subtracted into negative values. And everything else you don't wish to consider as 0.
Therefore when you call
Sum(Fields!calcfield.Value, "your dataset name")
from the textbox, you add the values between 40000 and 49999, and subtract values in ranges you wanted.
Please change the expression for the calculated field as per your need, the procedure will work.
You shouldn't go through all the values in a dataset directly from a textbox.
Hope it helps.

Crystal Reports equivalent of 'WHERE'

I'm familiar with SQL but not Crystal Reports. I'm trying to deal with an imported data set with 5 columns:
id deathDate giftDate giftAmount Dead
123 2008-01-06 2011-09-08 25.00 TRUE
456 2009-06-08 2011-10-13 10.00 TRUE
789 0 2011-12-04 50.00 FALSE
...
I'm trying to do a subquery but can't figure out what the CR equivalent of WHERE in SQL would be. I'd like to do something along the line of:
SELECT count(id) from tab1 where dead=TRUE
Any suggestions?
As Conrad and dotjoe have observed, the Crystal equivalent of the sql where clause is the Select Expert - you should be able to find this on the Report menu.
If you need to include both true and false Dead records in the detail section, but want a total for only those records where Dead is true, the simplest way to do this would be to set up a formula item. To do so:
Right-click on the Formula Fields option in the Field Explorer and select New... .
Enter a suitable formula field name, like DeadCount.
In the Formula editor, enter a formula like the following (assuming Dead is a string):
If {tab1.Dead} = 'TRUE' then 1
Use the x-2 button (or Alt-C) to check that the formula does not have any errors, then press the Save and Close button to exit the formula editor.
Drag and drop the new formula field from the Field Explorer onto anywhere in the report.
Right-click on the formula field that you have just added to the report and select Insert > Summary... from the menu.
In the Insert Summary dialog, specify the Summary operation as Sum and the Summary location as Grand Total (Report Footer), then click OK. A summarised field, labelled something like Sum of #DeadCount, should appear in the Report Footer. (You should now remove the un-summarised formula field from where you placed it in the report design area.)
This technique is essentially similar to including a summed case value in a sql query - something like: select sum(case when Dead = 'TRUE' then 1 end) as DeadCount from tab1
Add this to the record selection formula...
{datasetname.Dead} = true
//note: I'm not sure what data type that is but CR uses bool for bit and XSD bool
Then add a summary field to the report footer which does the count(id).
Or, if you need to display the dataset and only need a subquery you can use something called a "Running Total" field. In here you can do the count(id) and add the where clause to the necessary formula.