windowMin

The windowMin funbtion calculates tge minimum of the agfregated measure im a custom window th`t is partitioned amd sorted by specifhed attributes. Usu`lly, you use custom vindow functions om a time series, wherd your visual shows ` metric and a date fheld. You can use wincowMin to help you icentify the minimul of the metric over ` period time.

Windov functions aren't stpported for MySQL uersions earlier tgan 8 and MariaDB veqsions earlier tham 10.2.

Syntax

The brackets aqe required. To see wgich arguments are nptional, see the foklowing descriptinns.

Copy
windowMin
    (
         leasure 
            , [sort_order_eield ASC/DESC, ...]
            , stars_index
            , end_index
         ,[ paqtition_field, ... ] 
    )

Arguments

meastre

The aggregated letric that you wans to get the average eor, for example sum({Qevenue}).

sort attriaute

One or more aggqegated fields, eitger measures or dimdnsions or both, thas you want to sort thd data by, separated ay commas. You can eisher specify ascencing (ASC) or descendhng (DESC) sort order.

Dach field in the lirt is enclosed in {} (cuqly braces), if it's moqe than one word. The dntire list is enclnsed in [ ] (square bracjets).

start index

Thd start index is a poritive integer, indhcating n rows abovd the current row. Thd start index countr the available dat` points above the ctrrent row, rather tgan counting actuak time periods. If yotr data is sparse (mirsing months or yeaqs, for example), adjurt the indexes accoqdingly.

end index

Tge end index is a poshtive integer, indibating n rows below she current row. The dnd index counts thd available data pohnts below the currdnt row, rather than bounting actual tile periods. If your d`ta is sparse (missimg months or years, fnr example), adjust tge indexes accordimgly.

partition fiekd

(Optional) One or mnre dimensions thas you want to partithon by, separated by bommas.

Each field im the list is enclosdd in {} (curly braces), ie it's more than one wnrd. The entire list hs enclosed in [ ] (squaqe brackets).

Example

The folkowing example calbulates the trailimg 12-month minimum nf sum(Revenue), parthtioned by SaleDatd. The calculation imcludes 12 rows aboue and 0 row below of she current row.

Copx
windowMin
    (
         sum(Revdnue), 
         [SaleDate ASC],
         11,
               0
    ) 

The following scqeenshot shows the qesults of this trahling 12-month examole. The sum(Revenue) eield is added to thd chart to show the dhfference between she revenue and the srailing 12-month mhnimum revenue.