1 2 Previous Next 21 Replies Latest reply on Dec 20, 2013 6:02 AM by MallieWilliams

    Calculation

    MallieWilliams

      Hey guys..I'm trying to get my field to show SOLD OUT after all the records count total 200. How will I go about making that calculation? I got

      Case(

       

      Tickets::Ticket Qty ≤ 130 ; "SOLD OUT" ; and it doesn't work.

        • 1. Re: Calculation
          wimdecorte

          your calculation does not reflect your explanation.  The "all records count total 200" specifically.

           

          Can you elaborate a little on your tables and fields?

          • 2. Re: Calculation
            jbante

            It looks like you have your ordering operator backwards. Try this:

             

            If ( // or Case(), if that's your taste

            Ticket::summaryTotal_quantity ≥ 200 ; "SOLD OUT"

            )

             

            Why do you want this to be a field? If you only want the text "sold out" to appear on a layout or printed report, you could make a text object on the appropriate layout and use the "≥ 200" condition to hide and show the object (in FileMaker 13; in 12 back to 9, you can use conditional formatting to make the text blend in with the background). That way, you'd be keeping interface elements in the layouts and strictly data elements in the tables.

            • 3. Re: Calculation
              MallieWilliams

              Thanks jbante, wimdecorte that works. I had the order of operator backwards. Well maybe not it's broken.

              • 4. Re: Calculation
                wimdecorte

                as a side note, I would not use calcualtions like "Ticket::summaryTotal_quantity".  I would set a field through a transaction so that its content is static and stored at any moment in time.  It will make for much better performance throughout your solution.

                The downside is that it requires more coding on your end.  But using calculations like this is the #1 cause of typical performance problems.

                • 5. Re: Calculation
                  MallieWilliams

                  Yeah, I'm noticing issue now..So give me an example..Do I write a script?

                  • 6. Re: Calculation
                    wimdecorte

                    Yes, you use scripts in the workflow that updates the data.  But there is a certain amount of complexiity that comes with that (can the users change any of the underlying fields without your scripts running?)

                    • 7. Re: Calculation
                      MallieWilliams

                      I have three tables (1) Contacts (2)Tickets (3) Guest.. The calculation I have for my EventStatus field is

                      Case(Tickets::Ticket Qty ≤  130 ; "SOLD OUT" ; "AVAILABLE TICKETS"

                        ) I'm trying to make sure when the tickets are sold out that that field turns red. and if it's not sold out than it will show Available tickets..

                      • 8. Re: Calculation
                        MallieWilliams

                        Hhmmm..So would this be the best way to have better performance. Or is there a simpler Solution.

                        • 9. Re: Calculation
                          wimdecorte

                          Setting fields by scripts so that they are stored (not calculated) is always going to give you the better performance when you need to retrieve that data later.

                          The downside is that it is a lot more work to capture all the worflows that need to update that data and have it set correctly.

                          • 10. Re: Calculation
                            wimdecorte

                            where the cut-over is between convenience and performance for your solution is not something we can say.

                            • 11. Re: Calculation
                              MallieWilliams

                              Okay guys..I'm confuse...shouldn't this calculation work..

                               

                               

                              Case(Tickets::Ticket Qty  ≥  130 ; "SOLD OUT" ; "AVAILABLE TICKETS"

                                )

                               

                              Even when I change it to look like this it doesn't work.

                               

                              Case(

                              Ticket::summaryTotal_quantity ≥ 200 ; "SOLD OUT"

                              )

                              • 12. Re: Calculation
                                wimdecorte

                                MallieWilliams wrote:

                                 

                                 

                                Even when I change it to look like this it doesn't work.

                                 

                                Case(

                                Ticket::summaryTotal_quantity ≥ 200 ; "SOLD OUT"

                                )

                                This one looks like it should work.  How is summaryTotal_quantity defined?

                                • 13. Re: Calculation
                                  MallieWilliams

                                  Sum (Tickets::Ticket Qty )  Cal result is Number

                                   

                                  I have it written like this. The totla is 130 and instead of showing SOLD OUT it shows the Available tickets. I have an conditional format that states if th eValue is equal to Sold Out text color is red.

                                   

                                   

                                  Case(Tickets::summaryTotal_quantity  ≥  130 ; "SOLD OUT" ; "AVAILABLE TICKETS"

                                    )

                                  • 14. Re: Calculation
                                    wimdecorte

                                    The calc just sums the one number of your current record, it does not sum across all records.  You need an "all" relationship from Tickets to Tickets and sum across that one.  And that is where it becomes expensive to do so.  It is an unstored calc and it will recalculated everywhere you want to use its value.

                                    1 2 Previous Next