Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

String comparison in Crystal Reports and Excel

Posted on 2014-04-02
2
428 Views
Last Modified: 2014-04-02
Hi,
Can anyone please explain to me how Crystal Reports and Excel decide which is the greater of two text strings?

I would have thought that it would work like this:
a. compare character 1 of the two strings
b. If character 1 of both strings is identical, then compare character 2 of each string.
c. Continue until a non-identical pair of characters is found.
d. the string with the higher character is greater than the other one.

Take an example: Compare String 1 "ANTEATERS" to String 2 "AARDVARK"
Compare character 1 of the two strings
Both characters are identical ("A"), so compare character 2 of the two strings
N is greater than A so "ANTEATERS" is greater than "AARDVARK".

But....

In practice it isn't working that way, and I cannot figure out the logic these programs are using.

When I compare "C-" to "CA", Crystal Reports and Excel both tell me that "C-" is less than "CA".
But when I compare "C-W" to "CAB", Crystal Reports and Excel both tell me that "C-W" is greater than "CAB".

Can anyone explain to me how the programs are reaching this conclusion? Any help would be much appreciated!
0
Comment
Question by:vistamed
2 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39971959
Hi,

Excel sorts the strings but ignores the hyphen (-) and the apostrophe (') that's why you have this sorting result.

Reference
http://support.microsoft.com/kb/212144/en-us

Regards
0
 

Author Comment

by:vistamed
ID: 39972070
Hi Rgonzo1971,

Well I'll be dipped. It appears that Crystal ignores the hyphen in a similar way to Excel. I changed my formulas to replace the hyphens in my strings with a tilde, and sure enough the comparisons gave me the result I was expecting. My next question is why on Earth they arbitrarily decided to ignore hyphens and apostrophes, but that'll have to keep for another day.

Thanks for your help and your swift reply!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question