Skip to Content
author's profile photo Former Member
Former Member

Need help with string field formula

Post Author: dshallah

CA Forum: Formula

What I am trying to accomplish:

The report has item numbers and each item number has the

potential to be associated with up to three u2018binsu2019. So the fields are u2018item

numberu2019, u2018bin1, u2018bin2u2019 and u2018bin3u2019.

I tried to write a u2018if thenu2019 statement that would only show

records that had a value of less than 1 in each u2018binu2019 field. When I try to

write the statement I get a message that says u2018A string is required hereu2019 and

it highlights the number 1 in my statement. I have a feeling itu2019s because the u2018binu2019

fields are string fields and not number fieldsu2026? So I am not sure the proper

procedure to correct this. Thus help is needed and appreciated.

Here is what I wrote:

if {IC_LOC_HIST.BIN_NAME_1} < 1 then

{IC_LOC_HIST.BIN_NAME_1}

What is correct way to write a statement that will show me

the zero values in each column of bin fields?

Thanks!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

15 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 03:56 PM

    Post Author: sliese

    CA Forum: Formula

    If your bin fields are strings with "0" in them, you could convert them to a number first, then check if it's less than 1. Try this: if ToNumber({IC_LOC_HIST.BIN_NAME_1}) < 1 then

    {IC_LOC_HIST.BIN_NAME_1}

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 04:16 PM

    Post Author: kcheeb

    CA Forum: Formula

    You could also do the following comparsion in the if.

    if {IC_LOC_HIST.BIN_NAME_1} <> '0' then {IC_LOC_HIST.BIN_NAME_1}

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 04:18 PM

    Post Author: dshallah

    CA Forum: Formula

    Reply to :sliese I was able to create the formula without errors but when I tried to run the report it dumps me back into the formula writer and gives me the message 'The string is non-numeric' and highlights 'ToNumber({IC_LOC_HIST.BIN_NAME_1})'.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 04:19 PM

    Post Author: bettername

    CA Forum: Formula

    You must have a non-numeric value in there somewhere - up in the top left of the formula editor window, it'll show you the variables you've passed to the formula, which should help track down what's going on.

    You could try and check that the value is a number first by using something like:

    if isnull({IC_LOC_HIST.BIN_NAME_1}) = false and isnumeric({IC_LOC_HIST.BIN_NAME_1}) = false and then "Error - Should be a Number!"

    else

    if isnumeric({IC_LOC_HIST.BIN_NAME_1}) = true and tonumber({IC_LOC_HIST.BIN_NAME_1})<1 then {IC_LOC_HIST.BIN_NAME_1})

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 04:30 PM

    Post Author: dshallah

    CA Forum: Formula

    Reply to: kcheeb I tried it but it returned all data fields blank. Data that was previously there was removed.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 04:31 PM

    Post Author: sliese

    CA Forum: Formula

    That is probably because this field holds more than just "0"... does

    it have words in it as well? Maybe you could do this.... If {IC_LOC_HIST.BIN_NAME_1} = "0" then{IC_LOC_HIST.BIN_NAME_1}

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 04:36 PM

    Post Author: sliese

    CA Forum: Formula

    Hm, or maybe this:if isnumeric({IC_LOC_HIST.BIN_NAME_1}) and ToNumber({IC_LOC_HIST.BIN_NAME_1}) < 1 then{IC_LOC_HIST.BIN_NAME_1}

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 04:43 PM

    Post Author: dshallah

    CA Forum: Formula

    Reply to: betternameThanks for the 'if then' statement it certainly showed a lot of records (not all, but a lot) with the "Error - Should be a Number!" message. So that would point to the fact that there are non-numeric values in there. Is there a way to work around that fact and produce a formula that could give me the results I need? Thanks again!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 04:50 PM

    Post Author: dshallah

    CA Forum: Formula

    Reply to silese: I tried both and get all data fields blank.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 04:50 PM

    Post Author: bettername

    CA Forum: Formula

    Yeah, just use:

    if isnumeric({IC_LOC_HIST.BIN_NAME_1}) = true

    and tonumber({IC_LOC_HIST.BIN_NAME_1})<1 then {IC_LOC_HIST.BIN_NAME_1})

    That way, you're just displaying where stuff is a valid number, and it's <1.

    What kind of data are you getting that is non-numeric? It might be possible to have a "tidy-up" of the data before checking if it's a number or not...

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.