# Find maximum historical value of a Number Field (script)

**URL:** <https://community.fibery.io/t/find-maximum-historical-value-of-a-number-field-script/10621>\
**Category:** Fibery Showcase\
**Tags:** history, api\
**Created:** [March 23, 2026, 10:56am UTC](https://community.fibery.io/t/find-maximum-historical-value-of-a-number-field-script/10621 "2026-03-23T10:56:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![antoniokov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/antoniokov/32/201_2.png) [@antoniokov](https://community.fibery.io/u/antoniokov)\
**Post date:** [March 23, 2026, 10:56am UTC](https://community.fibery.io/t/find-maximum-historical-value-of-a-number-field-script/10621/1 "2026-03-23T10:56:06Z")

</div>

Okay, so we’ve got a bit carried away after this 😅:

> [@Find when a Number Field value crossed a threshold via History API (script)](https://community.fibery.io/t/find-when-a-number-field-value-crossed-a-threshold-via-history-api-script/10618):
>
> With the recent [introduction](https://community.fibery.io/t/march-12-2026-better-file-support-in-table-view-block-reordering-in-text-editor-via-keyboard-shortcuts-history-api/10537) of [History API](https://the.fibery.io/@public/User_Guide/Guide/History-API-470), we were able to solve a problem deemed too messy to solve before. I thought we might as well share the solution in case anyone faces a similar challenge. Problem to solve For each entity in a Database, understand when the value of a certain Number Field crossed a threshold. For example, for each Event, understand when the number of registrations crossed the 100 people mark — the point when an Event typically breaks even and is worth organizing. Sto…

Here’s another challenge solved in the same way — by creating a script working with our newly introduced [History API](https://the.fibery.io/@public/User_Guide/Guide/History-API-470).

### Problem to solve

For each entity in a Database, get the maximum historical value of a certain Number Field.

For example, understand what was the peak revenue for each customer.

### Solution

1. Filter entities to avoid querying everything in a Database (History API is quite slow by design).
2. For each entity, find the Field’s maximum historical value.
3. Write the results into a CSV file for manual inspection.
4. Take the CSV file and update another Field with the maximum historical value for each entity.

Here are the scripts:

> **[extract-historical-max-value · master · fibery-community / api-examples · GitLab](https://gitlab.com/fibery-community/api-examples/-/tree/master/extract-historical-max-value)**
>
> GitLab.com

As usual, feel free to use the scripts as is, fork them, or simply provide to your coding agent as an example when working with History API.

If you have any questions, please let me know!
