conditional running total in crystal reports

I'm using Crystal reports 2008 and sql server 2005. I've a report with data as following:
Dealer Name Account # Inspection Type
123 4000857733 DSI
123 4000857733 No Inspection
123 4000857733 No Inspection
I've a group on Dealer Name.
Whenever I've a situation like above, where there are multiple inspection types, I always want to do a distinct count of account number based on the inspection type but if there's DSI OR there's both DSI and No Inspection for the same account number, then the running total for the no inspection type condition should be 0 and it should be 1 for DSI. Like in above case, the total for DSI should be 1 and total for No Inspection should be 0.
Please help.

mkobrin: Yes a dealer can have multiple account numbers. For eg.,
Dealer Name Account # Inspection Type
123 4000857733 DSI
123 4000857733 No Inspection
123 4000857733 No Inspection
123 4000857734 DSI
123 4000857735 No Inspection
mlmcc: I did a group on inspection type and did a count. However, it works for other condition except if there's only No Inspection, like in above eg, I don't get a count of 1 for account number 4000857735. The business requirement is if there's more than 1 inspection type for the same account no, DSI and No Inspection, i should only count for DSI. If there's only No Inspection I should count it as No Inspection. In above example, my total for DSI should be 2 (1 for account # 4000857733 and 1 for account # 4000857734) and total for No Inspection should be 1 (for account # 4000857735). Instead I get total for DSI = 2 and total for No Inspection = 3. Please help. Thanks.

That formula won't work. I think what you meant is:
If {inspection_type} = "no inspection" then
1
else
0
Then distinct count that. If I do a distinct count on above formula, I get a count of 2. One for DSI and other for No Inspection.
Please advise.

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

The idea is that if there are no DSI records for an account, increment the "No Inspection" count by 1, otherwise increment the DSI count.

Then use formulas like the following to output the counts:

NumberVar no_insp_count

NumberVar DSI_count

I don't think you've said whether you're looking for counts for the whole report or each dealer or something else. If it's for the whole report, you can use formulas like the last 2 above in the report footer. If it's for the dealer, you can use the formulas in the dealer group footer, but you'll also need to put the first formula above (to initialize the variables) in the dealer group header (in addition to the report header), to reset the counts for each new dealer. If you need both, you'll need to add 2 more variables, one set for the dealer counts and one for the grand total counts.

I don't think a formula like that is going to work, for at least a couple of reasons. First of all, subash011 wants a separate count for DSI and "No Inspection", and obviously there's no way to get both of those by doing a distinct count on one formula. And that formula doesn't take into account the fact that the "No Inspection" count should only be incremented when an account has no DSI records.

Thanks everyone! You guys are great.
mlmcc: Thank you so much for uploading the report with database and looking into for me. I looked at the report and its partially right. It's working for DSI but not for No Inspection. For instance, the count for account no. 4000857735 for no inspection should be 1 but it's 0 in the report. But that was a huge help for me as I created my own version of formula based on your logic. Thanks again.

1. Set up your parameter at the report level as usual, check the box Multi-value, and set the Data Type to String
2. Set the Stored Procedure Parameter to varchar(max) --<---- This part here is the key to it's success
Example: @cst_key var…

Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message. In the To field, type your recipient's fax number @efaxsend.com.
You can even send a secure international fax — just include t…

Internet Business Fax to Email Made Easy -
With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number.
You'll receive secure faxes in your email, fr…