> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-3a82795f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# quantilesTimingArrayIf

> Ejemplo de uso del combinador quantilesTimingArrayIf

<div id="description">
  ## Descripción
</div>

Los combinadores [`Array`](/es/reference/functions/aggregate-functions/combinators#-array) y [`If`](/es/reference/functions/aggregate-functions/combinators#-if)
se pueden aplicar a la función [`quantilesTiming`](/es/reference/functions/aggregate-functions/quantileTiming)
para calcular cuantiles de valores de temporización en arrays en las filas donde se cumple la condición,
mediante la función de combinador de agregación `quantilesTimingArrayIf`.

<div id="example-usage">
  ## Ejemplo de uso
</div>

En este ejemplo, crearemos una tabla que almacena los tiempos de respuesta de la API para distintos endpoints,
y usaremos `quantilesTimingArrayIf` para calcular los cuantiles del tiempo de respuesta de las solicitudes exitosas.

```sql title="Query" theme={null}
CREATE TABLE api_responses(
    endpoint String,
    response_times_ms Array(UInt32),
    success_rate Float32
) ENGINE = MergeTree
ORDER BY ();

INSERT INTO api_responses VALUES
    ('orders', [82, 94, 98, 87, 103, 92, 89, 105], 0.98),
    ('products', [45, 52, 48, 51, 49, 53, 47, 50], 0.95),
    ('users', [120, 125, 118, 122, 121, 119, 123, 124], 0.92);

SELECT
    endpoint,
    quantilesTimingArrayIf(0, 0.25, 0.5, 0.75, 0.95, 0.99, 1.0)(response_times_ms, success_rate >= 0.95) as response_time_quantiles
FROM api_responses
GROUP BY endpoint;
```

La función `quantilesTimingArrayIf` calculará cuantiles solo para los endpoints con una tasa de éxito superior al 95 %.
El array devuelto contiene los siguientes cuantiles en este orden:

* 0 (mínimo)
* 0.25 (primer cuartil)
* 0.5 (mediana)
* 0.75 (tercer cuartil)
* 0.95 (percentil 95)
* 0.99 (percentil 99)
* 1.0 (máximo)

```response title="Response" theme={null}
   ┌─endpoint─┬─response_time_quantiles─────────────────────────────────────────────┐
1. │ orders   │ [82, 87, 92, 98, 103, 104, 105]                                     │
2. │ products │ [45, 47, 49, 51, 52, 52, 53]                                        │
3. │ users    │ [nan, nan, nan, nan, nan, nan, nan]                                 │
   └──────────┴─────────────────────────────────────────────────────────────────────┘
```

<div id="see-also">
  ## Véase también
</div>

* [`quantilesTiming`](/es/reference/functions/aggregate-functions/quantileTiming)
* [`Combinador If`](/es/reference/functions/aggregate-functions/combinators#-if)
