0

I have each row of data organized in column pairs. In my example below, the column pairs would be A:B, C:D, E:F, G:H and the pattern would continue.

  1. The first column in each pair contains "PlayerStat:<statName>" a string composed of "PlayerStat:" and a statName value which is itself a string such as "MaxHealth , "Damage" , "PhysicalResistance" , etc.
  2. The second column in each pair contains "exp;<n1>;<n2>;<n3>" a string composed of "exp;" and three numbers n each delimited by semi-colons.

Example Row

A B C D E F G H
1 PlayerStat:MaxHealth exp;1;1;100 PlayerStat:MaxHealth exp;1;1;1000 PlayerStat:MaxHealth exp;1;2;10000 PlayerStat:Damage exp;1;1000;235

Sample Row

I want to SUM all the n3 values where statName="MaxHealth". So for this example, it'd be "100+1000+10000 = 11100" (highlighted in blue font in the screenshot above).

Note: Can't change the values and the blue font is just for the purposes of this example.

Some of the approaches I tried are shown below.

=INDEX(A1:H1, 0, MATCH("PlayerStat:MaxHealth", A1:H1, 0) + 1)
=INDEX(SPLIT(B4, ";"), 0, 4)
=FILTER(A1:H1, "PlayerStat:MaxHealth"=A1:H1)

Approaches I tried

Link to my spreadsheet

0

1 Answer 1

0

Use the sum(iferror(filter())) pattern, like this:

=sum( iferror( 
  filter( 
    iferror(regexextract(B1:H1, "\d+$") + 0), 
    A1:G1 = "PlayerStat:MaxHealth" 
  ) 
) )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.