Google Sheets - How to round SUMs across several cells once a number limit is reached

时间:2019-03-19 15:10:04

标签: google-sheets google-sheets-formula

Let me start by sharing the spreadsheet I want to update: -redacted, since the issue is resolved now!-

You'll notice on the right there's a counter for "Total profit earned" showing Gems, Gold, Silver, then Copper. Currently, I have them auto-populated via SUM of the related columns to the left. What I'd like to see is:

  • When Copper goes above 999 in value, Silver is increased by 1, adding to the existing value there.

  • When Silver goes above 999 in value, Gold is increased by 1, adding to the existing value.

  • When Gold goes above 99 (yes 99, not 999 this time), Gem is increased by 1, adding to the existing value

  • A gem can stay as is and has no cap, it just needs to increase from Gold going over 99 each time.

How can I get the fields automatically updating once they hit these thresholds? I still need all of the data to be pulled from the columns on the left automatically. I'm a bit of a novice with spreadsheets so please spell this out for me as easily as you can.

EDIT: I tried the first proposed solution, however, I'd prefer to keep each currency type separate. Please consider that in your proposal.

3 个答案:

答案 0 :(得分:1)

为什么不使用一个数字来计算所有这些货币呢?

例如,您可以拥有4,202,754的数字,它将填充754的铜,填充202的银,填充4的金和填充0的宝石。

例如,我们将这个号码存储在B2中。 对于铜,我们将使用具有以下值的C2字段:     = MOD(B2,1000) 对于白银,我们将使用具有此值的D2字段:     = MOD(地板(B2 / 1000,1),1000) 对于黄金,我们将使用具有以下值的D2字段:     = MOD(地板(B2 / 1000000,1),1000) 对于宝石,我们将使用具有以下值的D2字段:     = FLOOR(B2 / 1000000000,1)

答案 1 :(得分:0)

={SUM(E3:E)+
  QUOTIENT(SUM(F3:F), 100)+
  QUOTIENT(MOD(SUM(F3:F), 100)+
  QUOTIENT(SUM(G3:G), 1000)+
  QUOTIENT(MOD(SUM(G3:G), 1000)+
  QUOTIENT(SUM(H3:H), 1000),1000),100),
  MOD(MOD(SUM(F3:F), 100)+
  QUOTIENT(SUM(G3:G), 1000)+
  QUOTIENT(MOD(SUM(G3:G), 1000)+
  QUOTIENT(SUM(H3:H), 1000),1000),100),
  MOD(MOD(SUM(G3:G), 1000)+
  QUOTIENT(SUM(H3:H), 1000),1000),
  MOD(SUM(H3:H), 1000)}

0

答案 2 :(得分:0)

=ARRAYFORMULA(VALUE({
 TEXT(IFERROR(IF(LEN(SUM(H3:H))=8, 0, LEFT(SUM(H3:H), LEN(SUM(H3:H))-8)), 0)+
      IFERROR(IF(LEN(SUM(G3:G))=5, 0, LEFT(SUM(G3:G), LEN(SUM(G3:G))-5)), 0)+
      IFERROR(IF(LEN(SUM(F3:F))=2, 0, LEFT(SUM(F3:F), LEN(SUM(F3:F))-2)), 0)+
      SUM(E2:E), "#0"),
 TEXT(IFERROR(IF(LEN(SUM(H3:H))=6, 0, RIGHT(LEFT(SUM(H3:H), LEN(SUM(H3:H))-6), 2)), 0)+
      IFERROR(IF(LEN(SUM(G3:G))=3, 0, RIGHT(LEFT(SUM(G3:G), LEN(SUM(G3:G))-3), 2)), 0)+
      RIGHT(SUM(F3:F), 2), "#0"),
 TEXT(IFERROR(IF(LEN(SUM(H3:H))=3, 0, RIGHT(LEFT(SUM(H3:H), LEN(SUM(H3:H))-3), 3)), 0)+
      RIGHT(SUM(G3:G), 3), "#0"),
 TEXT(RIGHT(SUM(H3:H), 3), "#0")}))

0