0

I am new to Emacs Lisp. I have this price table in Org mode. A small portion of it is shown here:

*** Destinations en France
| Destination              | Distance Km | Temps de trajet | Prix       |
|--------------------------+-------------+-----------------+------------|
| Ambilly                  |          10 |           00:30 | 45.00 Chf  |
| Annecy                   |          50 |           00:46 | 115.00 Chf |
| Annemasse                |          12 |           00:36 | 45.00 Chf  |
| Avoriaz                  |          86 |           01:29 | 197.80 Chf |
| Bourg-en-Bresse          |         112 |           01:24 | 257.60 Chf |
| Chamonix                 |          87 |           01:11 | 200.10 Chf |
#+TBLFM: $4=$2*2.30 Chf;f2

The table formula calculates prices for trips from the distance in km. But I would like to apply a different tariff for shorter trips. How would you write a conditional formula like that?

1
  • 2
    Instead of linking to a document, include a short example formatted as code to the question.
    – choroba
    Feb 24, 2022 at 12:29

1 Answer 1

1

Use if(condition, value1, value2) as documented at Formula syntax for Calc

#+TBLFM: $4=if($2<100,$2*1.2,$2*2.3) Chf;f2
#                         ^
#                         |
#                 Insert the second tariff here.
2
  • Hello choroba, sorry for the code. The solution is perfect, it looks so simple when you explain it. Thanks for the reference in orgmode manual.
    – alikgator
    Feb 24, 2022 at 20:18
  • "Thanks" on stackexchange = upvote / accept :-)
    – choroba
    Feb 25, 2022 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.