英文:
Years of seasons from dates in Google Sheets
问题
我明白你的要求,以下是翻译好的部分:
有一个包含身体部位和日期的数组。应该如何编写一个公式,首先按照身体部位分组,然后按照条件(每个身体部位的相邻日期之间的间隔不超过30天)分组,然后输出在该组内的年份?
例如,有6组日期。对于每组,我需要输出在该组内的年份(例如,如果有两年,2022年和2023年,那么输出22/23;如果只有一年,2021年,那么这一年加1,我们得到21/22)。
英文:
There is an array with a body part and dates. What should a formula look like that splits it first by body parts, and then by the condition (the interval between each next date is no more than 30 days for each body part) into groups, and then outputs the years that are within that group?
For example, there are 6 groups of dates. For each group I need to output the years that are within this group (for example, if there are two years 2022 and 2023, then output 22/23, if there is only one 2021, then this year + 1, we get 21/22)
https://docs.google.com/spreadsheets/d/1Haqs37snvnBUyGO8quwfpp-nGIMOaTdgyW1S7V3rUdg/edit#gid=0
答案1
得分: 2
以下是翻译好的部分:
"你可以尝试: =let(Σ;{1;scan(1;B3:index(B:B;match(;0/(B:B<>"";));lambda(a;c;if(isbetween(days(c;offset(c;-1;));0;30)*(offset(c;;-1)=offset(c;-1;-1));a;a+1)))}; map(Σ;lambda(Γ;let(Λ;text(minifs(B2:index(B:B;match(;0/(B:B<>"";));Σ;Γ);"y");Λ&&"/"&Λ+1)))) - group_1 output is kinda mismatching
with your expected output"
希望这有所帮助。如果您需要进一步的翻译或其他帮助,请随时提问。
英文:
You may try:
=let(Σ;{1;scan(1;B3:index(B:B;match(;0/(B:B<>"")));lambda(a;c;if(isbetween(days(c;offset(c;-1;));0;30)*(offset(c;;-1)=offset(c;-1;-1));a;a+1)))};
map(Σ;lambda(Γ;let(Λ;text(minifs(B2:index(B:B;match(;0/(B:B<>"")));Σ;Γ);"y");Λ&"/"&Λ+1))))
- group_1 output is kinda
mismatching
with your expected output
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论