Hi
I have below Data returned by query and i want to display Opening Balance.
I have following table named table1 with following data
Code
Ac# Date Debit Credit
1 1-Jan-15 100
1 1-Jan-15 100
1 2-Jan-15 200
1 2-Jan-15 300
1 3-Jan-15 200
1 3-Jan-15 100Now User gives parameter date range as following Date >= 2-Jan-15 and Date<= 3-Jan-15 Now the data will be display in report as following
Code
Ac# Date Debit Credit
Op Bal 200
1 2-Jan-15 200
1 2-Jan-15 300
1 3-Jan-15 200
1 3-Jan-15 100Thanks

Jignesh KumarRank #91 · 22.9K reputationPosted Dec 28, 2024, 2:08 AM EST
Hello Ramco,
If your store procedure return correct values then you need to display on crystal report then please use below one,
If the "Op Bal" row does not directly appear in the dataset, create a formula to calculate it within Crystal Reports:
Ramco RamcoRank #462 · 5.4K reputationPosted Dec 28, 2024, 9:09 AM EST
Hi Jignesh
Iam not getting through S.P. Where i should place formula so that first Opening Balance gets displayed then Detailstransactions during the period should get displayed.
Thanks
Jignesh KumarRank #91 · 22.9K reputationPosted Dec 29, 2024, 12:02 AM EST
In your Crystal Report, you need to include the formula I provided in my earlier response.
Chintan Gandhi80 reputationPosted Apr 15, 2025, 2:46 AM EDT
Hi Ramco,
You can use below query to get your achivable result.
-- Opening Balance
SELECT
'Op Bal' AS Ac#,
NULL AS Date,
NULL AS Debit,
SUM(Credit) - SUM(Debit) AS Credit
FROM table1
WHERE Date < '2015-01-02'
AND Ac# = 1
UNION ALL
-- Transactions in date range
SELECT
Ac#,
Date,
Debit,
Credit
FROM table1
WHERE Date >= '2015-01-02'
AND Date <= '2015-01-03'
AND Ac# = 1
ORDER BY
CASE WHEN Date IS NULL THEN 0 ELSE 1 END,
Date