• Resolved npacademy

    (@npacademy)


    Hello,

    If I have a spreadsheet with two columns, can I call the correct row for the Column B cell based on a value that is in column A next to it?

    For example, if I had:

    Col A | Col B
    X | Y

    Could I call Y by choosing its row on the basis that Col A said X?

    All of my column A will be different values, so no duplicates.

    This is the code I currently use, and I want to adapt the query:

    [gdoc key="link" class="no-datatables" query="SELECT B LIMIT 1 OFFSET 22"?strip="1"?use_cache="no" style="font-weight:normal; display:inline; position:relative; top:5px;"]

    • This topic was modified 6 years, 5 months ago by npacademy.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter npacademy

    (@npacademy)

    By the way, I tried what you said here:

    https://www.ads-software.com/support/topic/qdoc-query-under-other-notes-bottom-of-screen-example-request/

    I adjusted the key from ABCDEFGH to the link, and changed it in the php function in the functions.php file too.

    Then I call this, and it’s blank:

    [gdoc key="HTTP://LINKHERE" query="select B where C = '__WORDPRESS_USER_EMAIL__'" class="no-datatables" strip="1" use_cache="no" style="font-weight:normal; display:inline; position:relative; top:5px;"]

    And there is of course a value matching my email in there.

    Plugin Author Meitar

    (@meitar)

    Could I call Y by choosing its row on the basis that Col A said X?

    select B where A = "X"

    https://developers.google.com/chart/interactive/docs/querylanguage#where

    Thread Starter npacademy

    (@npacademy)

    Thank you, however I tried this as shown in my reply to this thread and it isn’t working.

    Here is the function I added:

    function filter_gdoc_query ($query, $atts) {
        if ('https://docs.google.com/spreadsheets/d/1xBMaz15TgtdMJn_SKPXGc4zWXrgVCeMIK2mP1adYoTs/edit?usp=sharing' !== $atts['key']) { return $query; }
        $cur_user = wp_get_current_user();
        return str_replace('__WORDPRESS_USER_EMAIL__', $cur_user->user_email, $query);
    }
    add_filter('gdoc_query', 'filter_gdoc_query', 10, 2);
    • This reply was modified 6 years, 5 months ago by npacademy.
    Plugin Author Meitar

    (@meitar)

    ˉ\_(ツ)_/ˉ

    What you describe wanting to do is accomplished by what you describe having done. If it doesn’t work, find your mistake and try again. Good luck.

    Thread Starter npacademy

    (@npacademy)

    I figured there was something wrong in the function, but I used it as stated on your reply elsewhere. Just thought you might have spotted an obvious error.

    I can’t see why it wouldn’t work as all I had to change was the key…

    Thread Starter npacademy

    (@npacademy)

    Ok I seem to have it working I think it was the styling I’d put in for some reason… Thanks for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Call cell based on value within an adjacent cell?’ is closed to new replies.