?
Solved

String comparison in Crystal Reports and Excel

Posted on 2014-04-02
2
Medium Priority
?
460 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
[X]
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
2 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

800 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