0

I like this application. I would like to build something similar but as a table inside a .org file.

This is an interesting and easy-to-understand particular case. But I would use this kind of approach for multiple situations.

Something like, the user types the hour value:

Hours per week: 40

    | Hour | Day | Week  | Month | Year    |
    |------+-----+-------+-------+---------|
    |   50 |     |       |       |         |

And, boom, all other cells are filled:

Hours per week: 40

    | Hour | Day | Week  | Month | Year    |
    |------+-----+-------+-------+---------|
    |   50 | 400 | 2,000 | 8,667 | 104,000 |

I suppose this is possible with an Elisp code snippet.

What would that code be?

1

1 Answer 1

1

You can use org spreadsheet formulas to do this.

| Hour | Day | Week | Month | Year |
|------+-----+------+-------+------|
|   50 |     |      |       |      |
#+TBLFM: $2=$1*8::$3=$2*5::$4=$3*4::$5=$3*52

With point anywhere in the TBLFM line, pressing C-c C-c generates the following:

| Hour | Day | Week | Month |   Year |
|------+-----+------+-------+--------|
|   50 | 400 | 2000 |  8000 | 104000 |
#+TBLFM: $2=$1*8::$3=$2*5::$4=$3*4::$5=$3*52

You'll want to update the values in the formula to suit your definition of a week, month year etc. It's up to you which values you want to hard-code in the formula, and which you want to include in the table to allow for easier updating.

See the linked manual page for more details and options.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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