Support » Plugin: TablePress » Calling other table cell values from another table?

Viewing 15 replies - 1 through 15 (of 23 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for the question.

    No, sorry that’s not possible 🙁 Shortcodes like that in table cells are only evaluated after the formulas in tables have been calculated. Thus, the formula in table 4 in your example only sees the Shortcode, which is not a formula or number, obviously.
    So, this is not possible. Sorry.

    Regards,
    Tobias

    Ok. Too bad… That feature would have been a nice one.
    If you end up doing that kind of an extension, please do tell me 😉

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    yes, the idea is indeed nice. I have an idea for a possible solution, but need to look into that a little bit more, and it might require some code changes first. I that turns out positive, I should be able to put this into an Extension, and I’ll then post here again.

    Regards,
    Tobias

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    good news 🙂 I developed an Extension that makes this possible.

    To use it, you’ll first need to replace your current version of TablePress with the latest development version from http://tablepress.org/download/tablepress-dev.zip (just replace the plugin folder with the one from the ZIP file).
    After that, just install and activate http://tablepress.org/download/extension/tablepress-shortcodes-before-formulas.zip just like a regular WordPress plugin.
    That will enable another Shortcode parameter that activates the functionality that Shortcodes are parsed before formulas. So, just extend your Shortcode from something like

    [table id=123 /]

    to

    [table id=123 shortcodes_before_formulas=true /]

    Regards,
    Tobias

    Hi,

    thanks a lot! I tested it to call cell values from two different tables and add them together in a third table cell and it works great! 🙂

    Now, I have come up with another question 🙂 Is it possible in a table cell to create a function which goes through a listed range of tables and i.e. adds the tables cell-values together?

    Using the examples above… You would now have to type the following in a table cell to get the different table cell-values added:
    =[table-cell id=1 cell=A1 /]+[table-cell id=2 cell=A1 /]+[table-cell id=3 cell=A1 /] and so on…

    But what if you could in a cell, type a function that gets for example all “A1” cell-values from tables with id = 1 -> n. The n could be i.e. 10, but if you only have 5 tables created (with id 1 to 5), the cell-function would then disregard the values from 6-10, because they don’t sill exist and would only throw an error in the table.

    This was a bit hard to explain, but hopefully you understand my question 🙂

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    great to hear that the Extension works!

    About that new question. Wow, you don’t have easy problems 🙂

    It could be possible to do this by creating a new Shortcode, like

    [table-sum tables=1-10 cell=A1 /]

    that internally gets rewritten to

    =[table-cell id=1 cell=A1 /]+[table-cell id=2 cell=A1 /]+[table-cell id=3 cell=A1 /]

    This is just some string manipulation. Tables that don’t exist could be removed from that list before it is executed.

    Regards,
    Tobias

    Hi,

    yeah, I was wondering of something like that.
    Why do you call these “problems”? I would preferably call them “enhancements” 😉

    About that Shortcode, it could be linked to all of the available math-functions that TablePress offers… For example, if you wanted to get the average value from a range of cell-values, you could just type something like this

    [table-average tables=1-10 cell=A1 /]

    So, what do you think… Could this “enhancement” end up in TablePress as an Extension (or something) in the near future? 😉

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    yes, “challenges” is a better word than “problems”, indeed 🙂
    However, it is a very special challenge that the vast majority of TablePress users will never need. Therefore, I don’t think that this should be part of TablePress itself.
    An Extension is the better option for this, but with this complexity, this is beyond what I can offer as free support right now, as I’m just too busy. I hope that you can understand. If you are interested though, we could try to work something out professionally (in that case, please send me an email to the address in the main plugin file “tablepress.php”), or you could of course try developing this yourself.
    Instead of creating for Shortcode for each math function, it might also be easier to have the Shortcode just return the values, and insert those into a math function, like

    =AVERAGE([table-values tables=1-10 cell=A1 /])

    Regards,
    Tobias

    Hi,

    I have discovered a couple of problems with this extension 🙂

    If I have a cell with the value of =J2+K2 it gives me a result of -1, which is OK. But then when I put the following in the cell =J2+K2<span>[table-cell id=1 cell=J2], [table-cell id=2 cell=K2]</span>
    It gives me an error of !ERROR! illegal character '<'. I assume it is the < between K2and span.

    Using <span> works if I have a normal numeric cell value of -1<span>[table-cell id=1 cell=J2], [table-cell id=2 cell=K2]</span>
    But that is not what I really want. I would first like to calculate a result and then when I hoover the cell it will display the used values in the calculation.

    Another thing that I noticed, was that if I used that span, Tablepress sorting did not work from negative to positive. It sorted the values from 0…1…-1…2…-2…3 and so on. And not -2…-1…0…1…2 and so on, as before.

    Any suggestions? 🙂

    Uups, found a typo, the span-code that I have used is

    <span>[table-cell id=1 cell=J2], [table-cell id=1 cell=K2]</span>

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    I’m very sorry, but you can not use <span> or any other text or HTML in a cell that has a formula. The formula can then not be evaluated, and there’s not way around that.

    About the sorting: Which sorting is this? The JS sorting on the frontend? Are all cells in the column really numbers? Can you post a link to the page with the table?

    Regards,
    Tobias

    Hi,

    ok, I’ll have to come up with some other solution then 🙂

    About the sorting, I noticed that it messes it up if you use a cell value like

    5<span>some text here</span>

    So, it seems that if you have in “numeric column” with some text also in it (though the text is hidden or not), then it will not sort the column anymore as a numeric one.
    But this sorting-case is not anymore a problem for me, now that it’s not possible to use <span>’s with formulas.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    yes, anything in a cell that is not a number (whether it is visible or not doesn’t matter, as it is in the code) will cause the DataTables JavaScript library to recognize these cells as strings and not as numbers, and these are sorted differently. If you want numeric sorting, you must only enter numbers.

    Regards,
    Tobias

    Hi,

    I apologize in advance for simple questions; I’m fairly new to WordPress and to TablePress. I’ve used TablePress to create several tables and I’m interested in calling table cell values from one table and displaying them in another table. Our dept. admin has us running WordPress 3.5.1 on a Multisite, we’re running TablePress 0.9-RC plus the two extensions: Parse Shortcodes before Formulas and Single Cell Content Shortcode.

    I cannot get values to display properly, I typed “=[table-cell id=12 cell=”A3″ /]” (without the quotes) in a cell in a new table, id=17, and when I view the page that has the shortcode for table 17, it displays the message ” !ERROR! Too many “=” “. Cell A3 in table 12 has the number 5.

    I’m trying to display table 17 on this page ( http://labs.russell.wisc.edu/wirc/test-species-summary-page/ ); I tried using this short code: [table id=17 shortcodes_before_formulas=true /].

    That probably wasn’t very clear, but please let me know what additional information you might need to help with my problem.

    Thanks in advance!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Your description indicates that the Shortcodes are not evaluated before the formulas, which would result in this.
    The reason for this could be that you are not using the development version from http://tablepress.org/download/tablepress-dev.zip which is required by the “Shortcodes before Formulas” Extension. A plain 0.9-RC is not enough for this yet.

    Could you check that please?

    Regards,
    Tobias

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Calling other table cell values from another table?’ is closed to new replies.