根据号码频率和日期填充日期

问题描述 投票:0回答:1

我前几天问过这个问题:根据频率填充日期

效果真的很棒! 我尝试对此进行修改,以便它可以接受每月和每年作为输入。我花了两天时间尝试修改最后一个灵魂,但没有成功......

+ A B C D E F
1 开始日期 结束日期 频率 成本 类别 公司
2 2024年2月2日 2024年2月17日 14 545 第一批农民
3 2024年2月2日 2024年9月3日 每月 80 驴子 战斗第一
4 2024年3月2日 2024年2月17日 7 23 内陆地区
5 2024年7月2日 2024年2月17日 3 23 牛仔优先
6 2024年7月2日 2025年9月10日 每年 90 大象 马戏动物园

制作输出:

+ A B C D E
1 日期 频率 成本 类别 公司
2 2024年2月2日 14 545 第一批农民
3 2024年2月2日 每月 80 驴子 战斗第一
4 2024年3月2日 7 23 内陆地区
5 2024年7月2日 3 23 牛仔优先
6 2024年7月2日 每年 90 大象 马戏动物园
7 2024年2月10日 7 23 内陆地区
8 2024年2月10日 3 23 牛仔优先
9 2024年2月13日 3 23 牛仔优先
10 2024年2月16日 14 545 第一批农民
11 2024年2月16日 3 23 牛仔优先
12 2024年2月17日 7 23 内陆地区
13 2024年2月3日 每月 80 驴子 战斗第一
14 2025年7月2日 每年 90 大象 马戏动物园

=sort(let(Ξ,tocol(,1), reduce(Ξ,Input!A2:index(Input!A:A,match(,0/(Input!A:A<>""))),lambda(a,c,vstack(if(iserror(a&""),Ξ,a),let(x,offset(c,,1),y,offset(c,,2),Σ,quotient(x-c,y)+1,if(or(c="",x=""),Ξ, hstack(sequence(Σ,1,c,y),chooserows(offset(c,,2,,4),sequence(Σ,1,1,0))))))))),1,1,2,)

这无需按年或按月即可工作。

我做了一个EXAMPLE_SHEET,这样可能更容易理解

google-sheets
1个回答
0
投票

更新的公式进行测试):

=sort(let(Ξ,tocol(,1), reduce(Ξ,Input!A2:index(Input!A:A,match(,0/(Input!A:A<>""))),lambda(a,c,vstack(if(iserror(a&""),Ξ,a),let(x,offset(c,,1),y,offset(c,,2),Σ,if(istext(y),datedif(c,x,switch(y,"Monthly","M","Yearly","Y")),quotient(x-c,y))+1,if(or(c="",x=""),Ξ,
 hstack(if(istext(y),index(edate(c,sequence(Σ,1,0,switch(y,"Monthly",1,"Yearly",12)))),sequence(Σ,1,c,y)),chooserows(offset(c,,2,,4),sequence(Σ,1,1,0))))))))),1,1,3,)

© www.soinside.com 2019 - 2024. All rights reserved.