If value is .. then .. else ..
Options
Frank Wieffering
Member ✭
Hi,
I recently started to explore Xano. But I have the following question.
We use a lot of variables. What I would like to do is a variable give a certain value depending on the value of another variable.
Even in some cases and want to use more the one if, else, then.
I found de conditional filter, but this is just half the solution.
I know I can use the if statement, but that's not very handy to have al this statement in the function stack.
I recently started to explore Xano. But I have the following question.
We use a lot of variables. What I would like to do is a variable give a certain value depending on the value of another variable.
Even in some cases and want to use more the one if, else, then.
I found de conditional filter, but this is just half the solution.
I know I can use the if statement, but that's not very handy to have al this statement in the function stack.
Comments
-
Have you looked at the custom functions? Composing can allow you more complex control flow in a more readable stack that I think you might be looking for here.
-
Hi Ray, thanks for your reply! This is an option but still there will be a lot of this functions.
In an other no-code platform you can use the following statement:
var:vat_include ? var:price * var:amount : round(price,2) * var:amount
(vat_include is true or false. After '?' is the true statement, and ':' stands for else.)
This not entirely no-code, but this is a powerful feature. And I really mis this possibility in Xano. -
We are working on the next iteration of our function stack and I'm in agreement that lots of conditionals feels overwhelming. We have some good ideas on how to make it feel more light weight.
In the meantime, you probably will be interested in the set_conditional filter. It will allow you to hide some of the logic inside a filter just as you would in your ternary operator example.
https://docs.xano.com/working-with-data/data-type-filters/manipulation-filters/conditional-set-filters
There is a good video in there, but I just released it doesn't go over set_conditional specifically.
Here is a screenshot to show an example. https://mrkr.io/s/622e202ff1f12b79fe56d592/0 -
Thanks. nice to hear this something Xano is reconsidering. At this point I choice the if-else function instead of the set_conditional because it's too limited. (Or I'm not exactly know at this point how this exactly works 😀 )
-
show a screenshot of what you did and I'll give you the alternative with set_conditional.
-
. For my defend, I just started...
Hereby a simple example.
Vatinclude is a boolean.
[CleanShot 2022-03-14 at 16.16.27.png] -
The conditional needs to be in the last parameter called conditional. Check out my screenshot. https://mrkr.io/s/622e202ff1f12b79fe56d592/0
value = price
set_conditional
path=(keep this empty)
value=netprice
conditional=vatInclude
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback