large expressions

Hi, 

This is an example of some expression that I used in a prototype.

IF(

ISNOTBLANK(
INDEX(SELECT(UBICACIONES GPS[Código de Tienda],DISTANCE([GPStienda],[GPS])<0.25),1)), INDEX(SELECT(UBICACIONES GPS[Código de Tienda],DISTANCE([GPStienda],[GPS])<0.25),1),

"DESCONOCIDA"

)

------

As you could see, technically AppSheet need to calculate 2 times the same code. I Know that in any programming language I could declare a Variable and that's all.

Is there any way to write a better code?

Thanks

Solved Solved
0 4 84
2 ACCEPTED SOLUTIONS

Steve
Platinum 4
Platinum 4
ANY(
  TOP(
    SELECT(
      UBICACIONES GPS[Código de Tienda],
      DISTANCE([GPStienda],[GPS])<0.25
    ),
    1
  )
  + LIST("DESCONOCIDA")
  - LIST("")
)

View solution in original post

Hi Steve, I will try your code...but it looks great. Thanks!!!

View solution in original post

4 REPLIES 4

Hello @astroboy1970, if that expression resides in an app formula, an action, or an action executed by a bot I don't think it will be a problem, but sadly there isn't a way of preventing such duplication of expressions, but you can always optimize them to minimize their impact, but I must ask, are you sure that expression returns the result that you require?

As I see it, it just returns the first store code that is closer than 0.25 units of distance (I dont remember which DISTANCE uses) in order of appearance in the spreadsheet, not strictly the closest OR the farther one.

Yes I used the first store and not the closest that is because:

1) I know that the stores are no to closer and the code works well for me .

2) Really I used option 1) because I do not know how to use build an expression to get the closer store ☹️

Steve
Platinum 4
Platinum 4
ANY(
  TOP(
    SELECT(
      UBICACIONES GPS[Código de Tienda],
      DISTANCE([GPStienda],[GPS])<0.25
    ),
    1
  )
  + LIST("DESCONOCIDA")
  - LIST("")
)

Hi Steve, I will try your code...but it looks great. Thanks!!!

Top Labels in this Space