0

Problem with this formula

sum((select Expenses).'Amount Spent' where Categories = "Gas")

sum((select Expenses).'Amount Spent' where text(Categories) = 8)

Where Categories is a Choice field.

6 replies

null
    • Daniel_Berrow
    • 1 yr ago
    • Reported - view

    You need the "where" within the select statement

    sum((select Expenses where text(Categories) = 8).'Amount Spent')
    

    or alternatively

    sum(select Expenses[text(Categories)= 8].'Amount Spent')

    Both should work the same

      • John_Halls
      • 1 yr ago
      • Reported - view

       text() will give the text value of the choice field so it should be

      sum((select Expenses where Categories = 8).'Amount Spent')
      

      or

      sum((select Expenses where text(Categories) = "Gas").'Amount Spent')
      

       Beware the second version of this as, although it reads easier in your code, "Gas" is hardcoded and won't work if that text is subsequently changed in the setup of your choice field, whereas 8 will work regardless of the text value

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr ago
      • Reported - view

        Thanks Daniel 👍

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr ago
      • Reported - view

        Thanks John 👍

      • Daniel_Berrow
      • 1 yr ago
      • Reported - view

       Ah yes you're right, I wasn't looking that it was actually trying to do the same thing so i assumed the choice had "8" in the field, my mistake

      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 yr ago
      • Reported - view

       @John Halls

      Excelent.

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 6Replies
  • 46Views
  • 3 Following