[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

A string is required here

Posted on 2011-02-23
15
Medium Priority
?
585 Views
Last Modified: 2012-06-27
Hi Guys,

How do I correct the below formula? I keep getting  an error message "A string is required here"

if {@sum_condition_value} <= 0 then "" 
else ToText({@bailing_text})
a-string-is-required-here.bmp
0
Comment
Question by:mcse2007
[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
  • 7
  • 5
  • 2
  • +1
15 Comments
 
LVL 16

Assisted Solution

by:sjklein42
sjklein42 earned 200 total points
ID: 34965836
How is sum_condition_value declared?  We need a little more context.
0
 
LVL 7

Author Comment

by:mcse2007
ID: 34965840
It is declared like the below. Is it incorrect?

CStr(sum ({Sheet1_.Condition value}, {Sheet1_.Bill#Doc#}),2,'')
0
 
LVL 44

Expert Comment

by:zephyr_hex (Megan)
ID: 34965893
@sum_condition_value is cstr
you are comparing it to a number when you have <= 0

sum_condition_value either needs to return a number, or the value you're comparing it to needs to be a character (such as "0")
0
What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

 
LVL 101

Accepted Solution

by:
mlmcc earned 800 total points
ID: 34965898
Since it is a string you have to compare it to a string.
if {@sum_condition_value} <= "0" then
   ""
else
    ToText({@bailing_text})

It might be better to compare to the numeric value since I am not sure if the string   "-123"   is less than the string "0"
 
if Val( {@sum_condition_value} ) <= 0 then
    "" 
else
    ToText({@bailing_text})

mlmcc

0
 
LVL 16

Assisted Solution

by:sjklein42
sjklein42 earned 200 total points
ID: 34965916
CStr makes a string.  You can use ToNumber to make it back into a number.

Since you made a string, this means that you need to test against a string, perhaps with  "0".

But that is not advisable.

You can do this:

if ToNumber({@sum_condition_value}) <= 0 then ""

Open in new window

Of you could make sum_condition_value be a number by calling ToNumber when it is declared, but that may break some other part of your code.

ToNumber(CStr(sum ({Sheet1_.Condition value}, {Sheet1_.Bill#Doc#}),2,'') )

Open in new window


Either way, you must match number to number, or string to string.
0
 
LVL 7

Author Comment

by:mcse2007
ID: 34965966
It is always iinspiring getting help from you guys.

Before, I close this post, one last question.

mlmcc, your second formula works perfect but if I rework it and i declared it like the below which also works, any disadvantages doing it this way?

if Val( {@sum_condition_value} ) <= 0 then
    ""
else
    ToText({@bailing_text})

Note: This {@sum_condition_value} simply equals to the the below,

CStr(sum ({Sheet1_.Condition value}, {Sheet1_.Bill#Doc#}),2,'')
0
 
LVL 7

Author Comment

by:mcse2007
ID: 34965973
my mistakes, it should be like this.

if Val( {@sum_condition_value} ) <= 0 then
    ""
else
    ToText({@sum_condition_value})
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 34966001
Since ({@sum_condition_value}) is already a string you don't need the ToText

ALso that will be slower since the formula is called twice.

One that might be fatser is
Local StringVar outstring := {@sum_condition_value};
If Left(outstring ,1) = '-' then
    ""
Else
   outstring


mlmcc
0
 
LVL 7

Author Comment

by:mcse2007
ID: 34966101
I now comprehend all the formulas except your last one...what does it mean?
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 34966210
Since it is a string II am testing for the - sign on the number.  If it is < 0 then it must have a leading - sign

mlmcc
0
 
LVL 7

Author Comment

by:mcse2007
ID: 34966236
thanks mlmcc....

finally, how do I get 10% (VAT or GST tax) of the value of the below

if Val( {@sum_condition_value} ) <= 0 then
    ""
else
   
Local StringVar outstring := {@sum_condition_value};
If Left(outstring ,1) = '-' then
    ""
Else
   outstring
0
 
LVL 7

Author Closing Comment

by:mcse2007
ID: 34966432
brilliant...you are worth more than these points i've assigned.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 34966570
Local StringVar outstring := {@sum_condition_value};
If Left(outstring ,1) = '-' then
    ""
Else
   CStr(Val(outstring ) * .1, 2)

mlmcc
0
 
LVL 7

Author Comment

by:mcse2007
ID: 34966643
cheers mlmcc.........dam u r 2 good. I wish I can allocate more points to you. but as said, you are worth more than all the points you earned here. thanks chief!!!
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 34966785
Your kind words are more than enough

mlmcc
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

656 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