WSaxton Posted December 26, 2012 Posted December 26, 2012 Alright folks I'm Confused on the nested If statement function while i understand that the if function is represented as If(Test on ; Result 1; Result 2) , I'm trying to wrap my mind around the nested function , heck i may be using the wrong function all together. What I'm more so looking for is this If(Test 1 ; Result 1(another If Statement with Result one) Result 2). I want to make multiple Items true prior to performing a calculation. SO If ( the Current year (on this layout) = Current year (On Different Table) and If( The Status of "Active" = Status (on Different Table) ; Sum (Field) ; if not then put 0) I have tried this statement and it doesn't work , If i remove the second IF statement then the first works with the result being the sum calculation. I'm thinking it is in my formatting of the calculation. Here is what i am currently using AddDollarFormat (If (Year=SLRP_PRJ_Projects||ID_Staff||::Year & SLRP_PRJ_Projects||ID_Staff||::Status= "Active" ; Sum(SLRP_PRJ_Projects||ID_Staff||::contract override))) Any Ideas?
comment Posted December 26, 2012 Posted December 26, 2012 I don't really understand what are you trying to accomplish. Nested Ifs are required* when multiple tests need to be performed in series, for example: If the year is current, then the result is x; if not, then check if the status is active: if yes, then the result is y, otherwise the result is z. I don't see this in your example that has only two possible results instead of three and the two tests need to be performed in conjunction. The other thing that jumps out is that you are using the & text operator instead of the and logical operator. --- (*) Actually, nested ifs are never "required" and it's much better to use the Case() function in these situations.
WSaxton Posted December 26, 2012 Author Posted December 26, 2012 Ok , Maybe if i descibe it like this I have a field on each layout and table called year , this field gives me the year that an item was created based of the Date created so if it was created 03/01/2012 the year shows 2012 I have a field called Status on the layouts and Tables these have mutiple status choices i am only looking for the Status of active right now So if the Recored was created in the year of 2012 and its status is Active the i want to add up all the contract amounts is what i am trying to do , I dont want it to calculate any thing other then if both statements are true. As for a case I thought a case was Case(Test one , Result one; Test two , Result two ; etc) How i write this in a case my first thoughts go to Case(Year=SLRP_PRJ_Projects||ID_Staff||::Year ; ?? ; SLRP_PRJ_Projects||ID_Staff||::Status= "Active"; ?; Sum(SLRP_PRJ_Projects||ID_Staff||::contract override) But what would i use as a result for each one? Obviously i want it two step through each test and if each test pass's then and only then Perform the sum calculation .
comment Posted December 26, 2012 Posted December 26, 2012 So if the Recored was created in the year of 2012 and its status is Active the i want to add up all the contract amounts is what i am trying to do , That would come down to something like = If ( Year = 2012 and Status = "Active" ; Sum ( Related::Value ) ) This will return the sum of related records when BOTH conditions evaluate as True; otherwise the result will be empty.
WSaxton Posted December 26, 2012 Author Posted December 26, 2012 awsome , thank you for helping to clear that up
Recommended Posts
This topic is 4407 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now