Forum Discussion

CamReid's avatar
CamReid
Copper Contributor
Jun 16, 2023
Solved

How to SUM only IF TRUE?

I feel like there should be an easier way to do this. Please help 🙂

 

=IF(O5,SUM(L5),0)+IF(O6,SUM(L6),0)+IF(O7,SUM(L7),0)+IF(O8,SUM(L8),0)+IF(O9,SUM(L9),0)+IF(O10,SUM(L10),0)+IF(O11,SUM(L11),0)+IF(O12,SUM(L12),0)+IF(O13,SUM(L13),0)+IF(O14,SUM(L14),0)+IF(O15,SUM(L15),0)+IF(O16,SUM(L16),0)+IF(O17,SUM(L17),0)+IF(O18,SUM(L18),0)+IF(O19,SUM(L19),0)+IF(O20,SUM(L20),0)

  • CamReid If your column O contains all Boolean values (TRUE/FALSE), then this will suffice:

    =SUM( L5:L20 * O5:O20 )

    If your column O contains all numbers that are to be implicitly interpreted as Boolean values, then:

    =SUMIF( O5:O20, "<>0", L5:L20 )

    (The spaces are not required, but are included for readability.)

     

    Note that for column O, empty cells and cells containing #N/A or an error value may not be handled as you expect.

     

     

  • SnowMan55's avatar
    SnowMan55
    Bronze Contributor

    CamReid If your column O contains all Boolean values (TRUE/FALSE), then this will suffice:

    =SUM( L5:L20 * O5:O20 )

    If your column O contains all numbers that are to be implicitly interpreted as Boolean values, then:

    =SUMIF( O5:O20, "<>0", L5:L20 )

    (The spaces are not required, but are included for readability.)

     

    Note that for column O, empty cells and cells containing #N/A or an error value may not be handled as you expect.

     

     

  • billfarrell's avatar
    billfarrell
    Copper Contributor

    CamReid 

    The result will always be the sum of O5:O20 since the IF will always be TRUE.
    What are you trying to compare?

    =IF(O5,SUM(L5),0) << this will always result in O5
    +IF(O6,SUM(L6),0) << this will always result in O6
    +IF(O7,SUM(L7),0) << this will always result in O7
    +IF(O8,SUM(L8),0) << this will always result in O8
    +IF(O9,SUM(L9),0) << this will always result in O9
    +IF(O10,SUM(L10),0) << this will always result in O10
    +IF(O11,SUM(L11),0) << this will always result in O11
    +IF(O12,SUM(L12),0) << this will always result in O12
    +IF(O13,SUM(L13),0) << this will always result in O13
    +IF(O14,SUM(L14),0) << this will always result in O14
    +IF(O15,SUM(L15),0) << this will always result in O15
    +IF(O16,SUM(L16),0) << this will always result in O16
    +IF(O17,SUM(L17),0) << this will always result in O17
    +IF(O18,SUM(L18),0) << this will always result in O18
    +IF(O19,SUM(L19),0) << this will always result in O19
    +IF(O20,SUM(L20),0) << this will always result in O20

    • CamReid's avatar
      CamReid
      Copper Contributor
      I currently am tracking my company sales, and I'm looking to create a "Totals" bar at the bottom of the table that only sums the revenue generated if they've installed the application (I have a checkbox in the O column I'm using as the TRUE/FALSE functionality for this purpose).

Resources