How do I get an exact number of unfiltered input rows from Flexmonster when the data is set to a CSV input file URL?

Answered
Charles Felish asked on April 22, 2026

To avoid having to load a large CSV file into browser memory, we set report.dataSource.filename directly to a URL hosting a generated CSV. However, because we don't read the file directly, we can't determine the number of rows in the CSV in our web client. Is there any way to get the information from Flexmonster after the report is loaded?

We tried setting up an event handler for reportComplete and then using pivot.flexmonster.getData, but the results were inconsistent at best. It might report correctly on the first call, but when the report was given a new CSV URL, the report would display correctly but getData did not return all the rows as expected. Additionally, based on the documentation is seems like getData contains totals and subtotals and length can't be read directly to get an accurate row count.

How can we reliably get the row count of the source data from Flexmonster after the data has been loaded? It is important that we count all rows, even if the particular Flexmonster report configuration might filter some out.

Thanks in advance!

2 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster April 23, 2026

Hello, Charles,

Thank you for writing to us.

The approach with getData can be used to retrieve the total row count by passing a custom slice in the options, including the "count" aggregation for a specific field. This slice would be presented by a single cell with the field's count, which matches the total row count without filters. We have prepared a JSFiddle illustrating this approach: https://jsfiddle.net/flexmonster/qe215whL/

However, this approach has a limitation - the field, whose count is queried by the getData method, must not include empty values in the dataset. This is due to empty values not being included in the "count" aggregation. Hence, if empty values are present for the field, the "count" aggregation would not correctly represent the total row count.

As a more stable alternative, we recommend handling this outside Flexmonster by exposing the total row count via a separate endpoint. This approach guarantees consistency regardless of the data structure. Additionally, it avoids unnecessary data processing on the client side, improving performance for larger CSV files.

Please let us know if our answer was helpful.

Best regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster May 12, 2026

Hello, Charles,

Hope you are doing well.
We are wondering if you had time to review the provided approaches for retrieving the row count.
Please let us know if our recommendations helped you.

Best regards,
Maksym

Please sign in or register to submit your answer