I am using a temporary index created for a report of:

Company + Item + strzero(MarginPerUnit,10,2)

The problem I am having is when the values are negative, as a -1 sorts before -2, then the numeric values aren't ascending.

Name      Item   Margin
Company1  Item1   -1
Company1  Item1   -2
Company1  Item1    4
Company1  Item1    8

Does anyone know what my index expression should be to sort the margin values in ascending order -2,-1,4,8?

Thanks, Gary

asked 30 Aug '12, 10:02

Gary's gravatar image

Gary
436131626
accept rate: 0%

edited 30 Aug '12, 10:20

Mark%20Wilkins's gravatar image

Mark Wilkins
7.2k226133


There might be more clever ways of doing it, but if you know the largest (in terms of absolute value) negative number, then you could just add a value to make them positive in the index. For example, if you know the negative numbers are never less than -1000000, this might work:

Company + Item + strzero( 1000000 + MarginPerUnit, 10, 2 )

The fact that you have a column name of MarginPerUnit makes me think you must be using either the VFP or ADT table type. If so, then you should be able to create an index such as follows and get the desired result.

Company;Item;MarginPerUnit

The semicolon is the the binary concatenation operator and is useful in indexes for combining fields of different types.

link

answered 30 Aug '12, 10:29

Mark%20Wilkins's gravatar image

Mark Wilkins
7.2k226133
accept rate: 26%

Mark, Thanks again.

(30 Aug '12, 12:32) Gary
Your answer to the original question.
If responding to a request for additional information, please edit the question or use the comment functionality.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×20

Asked: 30 Aug '12, 10:02

Seen: 1,564 times

Last updated: 30 Aug '12, 12:32

Advantage Developer Zone Contact Us Privacy Policy Copyright Info


Powered by Advantage Database Server and OSQA
Disclaimer: Opinions expressed here are those of the poster and do not necessarily reflect the views of the company.