Query that returns results that are at least a week apart
I have a google sheets spreadsheet that has lots of user data, timestamped. This data is entered into the google sheet by administration AND end users via a google form, so the data points don't come in at regular intervals. I want to be able to query against this datapool, but limit the results shown based a defined amount of time between result.
So say I wanted to query for Bob, I would get 3 results. Is it possible to query this data in a way that it would see the 1111 result, but disregard the 1112 result becuase it's within a week of the previous result? Really I'd like to be able to do this for any timeframe.
sql google-sheets google-sheets-query
add a comment |
I have a google sheets spreadsheet that has lots of user data, timestamped. This data is entered into the google sheet by administration AND end users via a google form, so the data points don't come in at regular intervals. I want to be able to query against this datapool, but limit the results shown based a defined amount of time between result.
So say I wanted to query for Bob, I would get 3 results. Is it possible to query this data in a way that it would see the 1111 result, but disregard the 1112 result becuase it's within a week of the previous result? Really I'd like to be able to do this for any timeframe.
sql google-sheets google-sheets-query
Possible. You would sort your data, find the time difference between adjacent timestamps and then pass it to query, where the diff >1wk. Share your sheet.
– TheMaster
Nov 21 '18 at 21:08
2
Trying to think this through - If you had 3 timestamps each four days apart, presumably you would want to keep the first and third, because they are more than a week apart?
– Tom Sharpe
Nov 21 '18 at 22:34
add a comment |
I have a google sheets spreadsheet that has lots of user data, timestamped. This data is entered into the google sheet by administration AND end users via a google form, so the data points don't come in at regular intervals. I want to be able to query against this datapool, but limit the results shown based a defined amount of time between result.
So say I wanted to query for Bob, I would get 3 results. Is it possible to query this data in a way that it would see the 1111 result, but disregard the 1112 result becuase it's within a week of the previous result? Really I'd like to be able to do this for any timeframe.
sql google-sheets google-sheets-query
I have a google sheets spreadsheet that has lots of user data, timestamped. This data is entered into the google sheet by administration AND end users via a google form, so the data points don't come in at regular intervals. I want to be able to query against this datapool, but limit the results shown based a defined amount of time between result.
So say I wanted to query for Bob, I would get 3 results. Is it possible to query this data in a way that it would see the 1111 result, but disregard the 1112 result becuase it's within a week of the previous result? Really I'd like to be able to do this for any timeframe.
sql google-sheets google-sheets-query
sql google-sheets google-sheets-query
edited Nov 21 '18 at 21:05
TheMaster
9,6003731
9,6003731
asked Nov 21 '18 at 17:52
d90d90
3822619
3822619
Possible. You would sort your data, find the time difference between adjacent timestamps and then pass it to query, where the diff >1wk. Share your sheet.
– TheMaster
Nov 21 '18 at 21:08
2
Trying to think this through - If you had 3 timestamps each four days apart, presumably you would want to keep the first and third, because they are more than a week apart?
– Tom Sharpe
Nov 21 '18 at 22:34
add a comment |
Possible. You would sort your data, find the time difference between adjacent timestamps and then pass it to query, where the diff >1wk. Share your sheet.
– TheMaster
Nov 21 '18 at 21:08
2
Trying to think this through - If you had 3 timestamps each four days apart, presumably you would want to keep the first and third, because they are more than a week apart?
– Tom Sharpe
Nov 21 '18 at 22:34
Possible. You would sort your data, find the time difference between adjacent timestamps and then pass it to query, where the diff >1wk. Share your sheet.
– TheMaster
Nov 21 '18 at 21:08
Possible. You would sort your data, find the time difference between adjacent timestamps and then pass it to query, where the diff >1wk. Share your sheet.
– TheMaster
Nov 21 '18 at 21:08
2
2
Trying to think this through - If you had 3 timestamps each four days apart, presumably you would want to keep the first and third, because they are more than a week apart?
– Tom Sharpe
Nov 21 '18 at 22:34
Trying to think this through - If you had 3 timestamps each four days apart, presumably you would want to keep the first and third, because they are more than a week apart?
– Tom Sharpe
Nov 21 '18 at 22:34
add a comment |
1 Answer
1
active
oldest
votes
Well it's easy enough to do as an ordinary formula that you can pull down like this, but I don't see a way of doing it as a query or array formula:
=iferror(if(istext(F1),index(A$2:A,match(true,(B$2:B=$F$1),0)),index(A$2:A,match(1,(B$2:B=$F$1)*((A$2:A-F1)>=7),0))))
where the person's name is in F1.
This is a fairly rough outline of an answer, I haven't taken account of any time part of the timestamps. The last two dates are only separated by 6 days, but the formula includes the third to last and the last one as mentioned in my comment because they are separated by 7 days.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417928%2fquery-that-returns-results-that-are-at-least-a-week-apart%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Well it's easy enough to do as an ordinary formula that you can pull down like this, but I don't see a way of doing it as a query or array formula:
=iferror(if(istext(F1),index(A$2:A,match(true,(B$2:B=$F$1),0)),index(A$2:A,match(1,(B$2:B=$F$1)*((A$2:A-F1)>=7),0))))
where the person's name is in F1.
This is a fairly rough outline of an answer, I haven't taken account of any time part of the timestamps. The last two dates are only separated by 6 days, but the formula includes the third to last and the last one as mentioned in my comment because they are separated by 7 days.
add a comment |
Well it's easy enough to do as an ordinary formula that you can pull down like this, but I don't see a way of doing it as a query or array formula:
=iferror(if(istext(F1),index(A$2:A,match(true,(B$2:B=$F$1),0)),index(A$2:A,match(1,(B$2:B=$F$1)*((A$2:A-F1)>=7),0))))
where the person's name is in F1.
This is a fairly rough outline of an answer, I haven't taken account of any time part of the timestamps. The last two dates are only separated by 6 days, but the formula includes the third to last and the last one as mentioned in my comment because they are separated by 7 days.
add a comment |
Well it's easy enough to do as an ordinary formula that you can pull down like this, but I don't see a way of doing it as a query or array formula:
=iferror(if(istext(F1),index(A$2:A,match(true,(B$2:B=$F$1),0)),index(A$2:A,match(1,(B$2:B=$F$1)*((A$2:A-F1)>=7),0))))
where the person's name is in F1.
This is a fairly rough outline of an answer, I haven't taken account of any time part of the timestamps. The last two dates are only separated by 6 days, but the formula includes the third to last and the last one as mentioned in my comment because they are separated by 7 days.
Well it's easy enough to do as an ordinary formula that you can pull down like this, but I don't see a way of doing it as a query or array formula:
=iferror(if(istext(F1),index(A$2:A,match(true,(B$2:B=$F$1),0)),index(A$2:A,match(1,(B$2:B=$F$1)*((A$2:A-F1)>=7),0))))
where the person's name is in F1.
This is a fairly rough outline of an answer, I haven't taken account of any time part of the timestamps. The last two dates are only separated by 6 days, but the formula includes the third to last and the last one as mentioned in my comment because they are separated by 7 days.
answered Nov 22 '18 at 11:25
Tom SharpeTom Sharpe
12.2k31224
12.2k31224
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417928%2fquery-that-returns-results-that-are-at-least-a-week-apart%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible. You would sort your data, find the time difference between adjacent timestamps and then pass it to query, where the diff >1wk. Share your sheet.
– TheMaster
Nov 21 '18 at 21:08
2
Trying to think this through - If you had 3 timestamps each four days apart, presumably you would want to keep the first and third, because they are more than a week apart?
– Tom Sharpe
Nov 21 '18 at 22:34