Calculate by pattern matching

  • I need help to calculate the average based on SKU patterns.


    For example, if the SKU begins with "CZD", then take the average SKU that meets that pattern.



    [TABLE="width: 327"]

    [tr]


    [TD="class: xl24, width: 210, bgcolor: transparent"]SKU[/TD]
    [TD="class: xl24, width: 117, bgcolor: transparent"]Items Sold[/TD]

    [/tr]


    [tr]


    [TD="class: xl23, bgcolor: transparent"]CZD80[/TD]
    [TD="class: xl23, bgcolor: transparent, align: right"]45[/TD]

    [/tr]


    [tr]


    [TD="class: xl22, bgcolor: transparent"]AAK99[/TD]
    [TD="class: xl22, bgcolor: transparent, align: right"]46[/TD]

    [/tr]


    [tr]


    [TD="class: xl22, bgcolor: transparent"]CZD50[/TD]
    [TD="class: xl22, bgcolor: transparent, align: right"]14[/TD]

    [/tr]


    [tr]


    [TD="class: xl22, bgcolor: transparent"]AAK45[/TD]
    [TD="class: xl22, bgcolor: transparent, align: right"][/TD]

    [/tr]


    [tr]


    [TD="class: xl22, bgcolor: transparent"]HHU22[/TD]
    [TD="class: xl22, bgcolor: transparent, align: right"]76[/TD]

    [/tr]


    [tr]


    [TD="class: xl22, bgcolor: transparent"]PPH34[/TD]
    [TD="class: xl22, bgcolor: transparent, align: right"]100[/TD]

    [/tr]


    [/TABLE]

  • Re: Calculate by pattern matching


    If your 'SKU' header is in A1:


    =SUMIF($A$2:$A$7,"="&LEFT(A2,3)&"*",$B$2:$B$7)/COUNTIF($A$2:$A$7,"="&LEFT(A2,3)&"*")


    (in D2 and copy down)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!