# Extract all data from a composite aggregation in Power BI/Power Query using after\_key

**URL:** https://discuss.elastic.co/t/extract-all-data-from-a-composite-aggregation-in-power-bi-power-query-using-after-key/331868
**Category:** Elasticsearch
**Created:** [May 1, 2023, 12:34pm UTC](https://discuss.elastic.co/t/extract-all-data-from-a-composite-aggregation-in-power-bi-power-query-using-after-key/331868 "2023-05-01T12:34:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Felipe\_Moura\_da\_Silv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felipe_moura_da_silv/32/120478_2.png) [@Felipe\_Moura\_da\_Silv](https://discuss.elastic.co/u/Felipe_Moura_da_Silv)
#### Post date: [May 1, 2023, 12:34pm UTC](https://discuss.elastic.co/t/extract-all-data-from-a-composite-aggregation-in-power-bi-power-query-using-after-key/331868/1 "2023-05-01T12:34:00Z")

</div>

Hey guys!  
I'm having a challenge importing data from an elasticsearch query into Power BI. I'm making the call and the results arrive, but only the limit of 16000 results that the API allows due to performance.

I need Power BI to receive all the data from this aggregated query, has anyone had to do this?

The scroll method that is in the following link does not work in aggregated queries, and due to the large volume of data I cannot use the scroll to pull all the results, so I need to do this with the aggregated query.

The idea would be to create a kind of loop that takes the after\_key value and pulls the following results until it runs out. Would anyone help me to solve this doubt?

> **[Getting Data from Elastic Stack with REST with Scroll](https://community.powerbi.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/230222/page/2)**
>
> Hello,   I'm pulling data into Power BI using the Elastic Stack REST API, but I'm running into a problem when trying to pull more than 10k records.   In order to do so, I need to use the scroll...

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 29, 2023, 12:34pm UTC](https://discuss.elastic.co/t/extract-all-data-from-a-composite-aggregation-in-power-bi-power-query-using-after-key/331868/2 "2023-05-29T12:34:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
