Forum Discussion

CHende77's avatar
CHende77
Copper Contributor
Jul 26, 2022
Solved

Summing values based on Condition

Hello Excel Experts, I am using excel (version 2206) on a PC with Windows 10. I want to be able to determine lengths of walls based on their type (P1, P2, or P3). The sheet I have will give the type...
  • Deleted's avatar
    Deleted
    Jul 26, 2022

    CHende77 

    Hi,
    based on the example you provided you could try to replicate your result by using this formula:
    Formula for cell G6:
    =IF($F6<>$F7;IF($F6<>$F7;$H6;0)-IF(ISNUMBER($G5);SUM($G$5:$G5);0);0)
    Then copy & paste the formula down to the last row of your table.
    Now this should work, if you don't change the layout of the sheet.

    To return the sum for each type you could try this:
    Formula for cell F1 (copy & paste to cell F2 and cell F3):
    =SUMIF($F$6:$F$19;MID($E1;FIND("P";$E1;1);LEN($E1)-6);$G$6:$G$19)
    Now here you need to reshape the cell ranges (underlined in the formula above) based on the range of your table. For example if your table ranges from row 6 to row 25 you would exchange all 19's in the formula with a 25.

    Hope it helps.