SOLVED

Obtener el valor promedio de un rango pero solo de las celdas visibles

Brass Contributor

Saludos a todos: tengo esta formula: =SI.ERROR(PROMEDIO.SI.CONJUNTO(G8:G3000;$B8:$B3000;">="&$A6;$B$8:$B$3000;"<="&$B$6);0) que devuelve el valor promedio de un rango de acuerdo a un filtro de fechas, funciona bien, pero me gustaría que, adicionalmente, me mostrara solo las celdas visibles del rango, ya que puedo aplicar filtros a la hoja y reducir la cantidad de celdas visibles. Agradeceré todos los comentarios, gracias

6 Replies
best response confirmed by a7024782 (Brass Contributor)
Solution

@a7024782 

If you're on 365, this might work for you:

=MAX(MAP(B8:B3000,G8:G3000,LAMBDA(b,g,IF(AND(b>=$A$6,b<=$B$6,SUBTOTAL(102,b)=1),g,0))))
Gracias por la respuesta, estoy con excel 2016,intentare adaptarla

Hi @a7024782 

 

Hi

If you're looking to calculate an average with conditions on hidden/visible rows the following should work on Excel 2016

 

_Screenshot.png

in G3:

=IF(
    SUMPRODUCT(SUBTOTAL(102,OFFSET(B8,ROW(B8:B3000)-ROW(B8),,1))) = ROWS(B8:B3000),
    AVERAGEIFS(G8:G3000, B8:B3000,">="&A6, B8:B3000,"<="&B6),
    SUMPRODUCT(
        SUBTOTAL(102,OFFSET(B8,ROW(B8:B3000)-ROW(B8),,1)),
        (B8:B3000 >= A6) * (B8:B3000 <= B6),
        G8:G3000
    )
    / SUMPRODUCT(
            SUBTOTAL(102,OFFSET(B8,ROW(B8:B3000)-ROW(B8),,1)),
            (B8:B3000 >= A6) * (B8:B3000 <= B6)
    )
)

 

Sample available in the attached file with a Table (same Dates & Values) to check the result

Gracias, una magnifica solución!
Glad I could help & Thanks for proving feedback

Hi @Patrick2788 

 

It seems @a7024782 was looking to compute an AVERAGE. Your LAMDBA is really nice but not sure it generates an AVG ;)

1 best response

Accepted Solutions
best response confirmed by a7024782 (Brass Contributor)
Solution

@a7024782 

If you're on 365, this might work for you:

=MAX(MAP(B8:B3000,G8:G3000,LAMBDA(b,g,IF(AND(b>=$A$6,b<=$B$6,SUBTOTAL(102,b)=1),g,0))))

View solution in original post