Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Summarizing multiple if then statements

Status
Not open for further replies.

ghostofelmo

IS-IT--Management
Jul 20, 2006
18
US
I am using the following formula

If {P Folder 1.Material} = "Stone" then {P Folder 1.$} else 0 +
If {P Folder 2.Material} = "Stone" then {P Folder 2.$} else 0+
If {P Folder 3.Material} = "Stone" then {P Folder 3.$} else 0+
If {P Folder 4.Material} = "Stone" then {P Folder 4.$} else 0+
If {P Folder 5.Material} = "Stone" then {P Folder 5.$} else 0

The result that I get is only the first {PFolder 1.$} and not the result of the rest.
 
If-then-else statements will only continue to evaluate while the statement is false. So if the first part of your statement

If {P Folder 1.Material} = "Stone" then {P Folder 1.$} else 0

is evaluated and {P Folder 1.Material} does equal "Stone" then the rest of the statement will be ignored.

What exactly are you trying to achieve here?

-Steve


"if at first you don't succeed, sky diving is not for you"!!! :eek:)
 
As TheBlondOne says, only the first linr will work. Depending on your aim, you might want something like
Code:
If {P Folder 1.Material} = "Stone" then {P Folder 1.$} 
else If {P Folder 2.Material} = "Stone" then
This might end else 0. assuming you want just one result.

If you are wanting all five results, I'd advise doing five formula fields and then stiching them together in a sixth that adds the five. @res1 + @res2 + @res2... or @res1 & @res2 & @res2...

Note also that a formula field will stop when it hits a null. You might need an IsNull test first.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
I have been using Excel formulas too much. I used the 5 formula fields then added them up. Thanks!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top