Google表格的SCAN函数

huangapple go评论106阅读模式
英文:

Google sheets SCAN function

问题

我正在尝试让表格自动向下滚动并给我季度数据,像这样:

1Q08
2Q08
3Q08
4Q08
1Q09
2Q09
3Q09
4Q09
1Q10

等等,在一列中使用一个公式。

我认为可以使用SCAN函数来实现,但在使用它时出现了问题。

我尝试过以下公式:

  1. SCAN("1Q08",B1:B9,LAMBDA(a,c,
  2. LET(
  3. quart, index(split(c,"Q"),,1),
  4. year, index(split(c,"Q"),,2),
  5. new_quart, if(quart=4,1,quart+1),
  6. new_year, if(quart=4,year+1,year),
  7. new_quart&"Q"&new_year
  8. )
  9. )
  10. )

它从空白开始,所以不能累积,但我在初始值中放入了 1Q08。这个能实现吗?

英文:

I'm trying to get the sheets to auto go down and give me quarters like this

  1. 1Q08
  2. 2Q08
  3. 3Q08
  4. 4Q08
  5. 1Q09
  6. 2Q09
  7. 3Q09
  8. 4Q09
  9. 1Q10

and etc, going down a column using one formula.

I think it is possible using the SCAN function, but having problems with it.

I've tried

  1. SCAN("1Q08",B1:B9,LAMBDA(a,c,
  2. LET(
  3. quart, index(split(c,"Q"),,1),
  4. year, index(split(c,"Q"),,2),
  5. new_quart, if(quart=4,1,quart+1),
  6. new_year, if(quart=4,year+1,year),
  7. new_quart&"Q"&new_year
  8. )
  9. )
  10. )

It's starting with a blank so it can't accumulate, but I put 1Q08 in the initial value. Is this possible to do?

答案1

得分: 1

这里是一个方法:

  1. =let(initial_,8,seq_,4,years_,3,
  2. tocol(reduce(,sequence(years_,1,0),lambda(a,c,{a;index(sequence(seq_)&"Q"&text(initial_+c,"00"))})),1))
  • 你可以根据需要更改参数 initial_seq_years_
英文:

Here's one approach:

  1. =let(initial_,8,seq_,4,years_,3,
  2. tocol(reduce(,sequence(years_,1,0),lambda(a,c,{a;index(sequence(seq_)&"Q"&text(initial_+c,"00"))})),1))
  • you may change the parameters initial_,seq_,years_ as per choice

Google表格的SCAN函数

huangapple
  • 本文由 发表于 2023年6月21日 23:54:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76525122.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定