Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have a Crystal Report which have

OrderNo Customer Amount
*0553 Ron 150.0
2635 Bert 50.0
*4231 James 70.0
Total 270.0



How can I get the total/SUM of all Amount without including the Order No that contains '*'
I have have try using the LIKE but I can't get the result

I've used a formula sum


IF NOT ({Amount} like "*") THEN
SUM(Amount)
Posted
Updated 8-May-13 5:39am
v2
Comments
Kschuler 8-May-13 11:19am    
How did you use the LIKE? Click the Improve question link and add the code you used. We can help you make it work.

1 solution

When I saw what code you used, I immediately thought you were not using the LIKE the correct way. When you use a LIKE, you would usually include a wildcard character. For example, when searching for things that start with the letter M, you'd write something along these lines: {Name} LIKE "M%". The percent sign is a wild card character that means any number of characters of any value can come after it. If you wrote {Name} LIKE "%M" it would return values that ended in the letter M.

This, however is not your entire problem. The percent sign is used in a lot of SQL languages to be the wildcard character, but it seems that in Crystal Reports the wildcard character is the asterisk.

So when you say {Amount} LIKE "*" you are actually asking it to return EVERYTHING. I did some googling and I've found other people with the same issue but not a whole lot of answers as to the best solution. Here[^] is the best I could find. I thought you could play around and try to use an escape character to signify that you want to search for an asterisk and not use it as a wildcard, which might look something like this:
{Amount} LIKE "/**". (The slash says the next character shouldn't be treated as a special character or wildcard. The second asterisk IS used as a wildcard so it will return anythign that STARTS with an asterisk.) But I'm not sure if Crystal Reports uses escape characters. You could probably do somemore research to find out.

Good luck.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900