11 Replies Latest reply on May 5, 2010 3:46 PM by comment_1

    If or case?

    Russell904

      Title

      If or case?

      Post

      I am extremely new to filemaker, But learning to like it quickly. I have a form I could use some help on, basically we test equipment to make sure it works correctly, so machine type 1 might take 1 hour, type 2 takes 2 hours, etc.. As you enter the counts of equipment, it adds up the hours it'll take, so lets say it is 100 hours, then I have a menu for how many technicians will be working on the project, so if you select 4, I need it to divide the hours up by 4, and enter them into seperate fields.Example below, basically the Blue 1 is where the total hours are, the 2 is where you select the # of techs from a drop down menu, 1-4 and then 3 is where it divides the time from 1 by the number of techs selected, and enters the hours for each tech into TECH1-4.

       

        • 1. Re: If or case?
          mrvodka

          Instead of tech1,2,3,4 fields you should be using a related table with each one being its own related record.

          • 2. Re: If or case?
            aammondd

            Case is a much better function than if in many many cases no pun intended.

             

            It looks like you are going to run a script after the selected number of techs.

             

            And the calculation is going  to be based on the number selected.

             

            Case is definitely better than If for this and is expandable if for instance you ever need 5 techs etc.

             

            You can do the division math once

            then Populate  the fields based on the Case

            or you can do the math in each case but that isnt very efficient.

             

             

             

            • 3. Re: If or case?
              aammondd

              Im just going to second Mr. Vodka here but that means more structural change to your database but as I said in my earlier reply it makes it more flexible in the long run.

              • 4. Re: If or case?
                Russell904

                like I said, I am new when it comes to FMP. This is my 2nd day on it.. This is what I have for each TECH1-4 field:

                 

                Case (
                techs=1;
                Abs(FIRSTTOTAL)/1;
                techs=2;
                Abs(FIRSTTOTAL)/2;
                techs=3;
                Abs(FIRSTTOTAL)/3;
                techs=4;
                Abs(FIRSTTOTAL)/4;
                )




                • 5. Re: If or case?
                  aammondd

                  Well thats one way  to do it.

                   

                  This would be  better

                  Tech 1 field

                  Case (
                  techs=1;
                  Abs(FIRSTTOTAL)/1;
                  techs=2;
                  Abs(FIRSTTOTAL)/2;
                  techs=3;
                  Abs(FIRSTTOTAL)/3;
                  techs=4;
                  Abs(FIRSTTOTAL)/4;
                  0)

                   

                  Tech 2 field

                  Case (
                  techs=2;
                  Abs(FIRSTTOTAL)/2;
                  techs=3;
                  Abs(FIRSTTOTAL)/3;
                  techs=4;
                  Abs(FIRSTTOTAL)/4;
                  0)

                  Tech 3 field

                  Case (
                  techs=3;
                  Abs(FIRSTTOTAL)/3;
                  techs=4;
                  Abs(FIRSTTOTAL)/4;
                  0)

                  Tech 4 field

                  Case (
                  techs=4;
                  Abs(FIRSTTOTAL)/4;
                  0)

                   

                  This way only  you dont get the same value for all fields when there is less than 4 techs assigned











                  • 6. Re: If or case?
                    Russell904

                    It's giving me an error, Either an operator was ommitted, this function cannot be found, or "(" was not expected here.  And, it highlights the first ABS(

                     

                     

                     

                    Thank you for all of your help, I will get it one day. :)

                    • 7. Re: If or case?
                      aammondd

                      However if you were to do this with a scrip trigger it would look like this

                       

                      Set Variable ["$splitamt"; Abs(FirstTotal/Techs))

                      Set Field[Tech1;$splitamt]

                      If[Techs = 2]

                        Set Field[Tech2; $splitamt]

                      Else

                       Set Field[Tech2; 0]

                      End- if

                      If[Techs = 3]

                        Set Field[Tech3; $splitamt]

                      Else

                       Set Field[Tech3; 0]

                      End- if

                      If[Techs = 4]

                        Set Field[Tech4; $splitamt]

                      Else

                       Set Field[Tech4; 0]

                      End- if

                      • 8. Re: If or case?
                        aammondd

                        you may need to put the function in ()

                        • 9. Re: If or case?
                          comment_1

                           


                          Russell904 wrote:

                           

                          Case (
                          techs=1;
                          Abs(FIRSTTOTAL)/1;
                          techs=2;
                          Abs(FIRSTTOTAL)/2;
                          techs=3;
                          Abs(FIRSTTOTAL)/3;
                          techs=4;
                          Abs(FIRSTTOTAL)/4;
                          )


                           

                          Which basically comes down to =

                           

                          Abs ( FIRSTTOTAL ) / techs

                           

                          However, I too would suggest you review your structure.






                          • 10. Re: If or case?
                            Russell904

                            I am still playing with it, I know it could be done differently, the reason I did it like this is because this is based off of an excel file we're using now to do this with, The big guys want it to look similar to the excel file, As for adding the data to the tech1-4, they should all have numbers in them, basically if it's 100 hours split between 4 techs, we should bill 25 hrs at tech1 rate, 25 hrs at tech 2 rate, 25 at tech3 rate, and 25 at tech4 rate. So, each field should have info, so if it were 3 techs, tech1-3 would have equal numbers while 4 would be empty.

                             

                            Again, I apologize for how I am coming off on here, I feel like an idiot when it comes to this.. I can do delphi and php code all day long, but FMP is kicking my butt.

                            • 11. Re: If or case?
                              comment_1

                              I am not really sure what this is about, but it seems like you should have something like :

                               

                              Jobs -< Tasks >- Staff

                               

                              In the Tasks table you enter the number of hours and lookup the applicable rate from Staff. Multiply these two, and sum up the results in the Jobs table.