Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
KremenaK
Frequent Visitor

Where to embed SQL Query for Amazon Athena in Power Query

Hello,
I have successfully connected Power BI with AWS/Amazon Athena (via ODBC connector), but can't figure out where to write a sql statement (or what M function to use) to query the underlying data in order to limit the results as current dataset has millions of rows.

Doing simple transformations in Power Query doesn't help...data still too lage to load to model.

Thank you!

1 ACCEPTED SOLUTION
edhans
Super User
Super User

There is no place to do it per Using the Amazon Athena Power BI connector - Amazon Athena
You need to have a view created on Athena that limits the data as desired, then connect to that.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

12 REPLIES 12
Syndicate_Admin
Administrator
Administrator

Can you please help how did you write direct query for AWS Athena table ? 

I am using ODBC connector to connect  Athena , using import , and full tables are coming to my data set .

Please help .

When you connect to Athena via ODBC driver you can either write a SQL query (see my other response above) or in Power Query select the columns you need, filter data, do transformations, etc. and load into your model.

Syndicate_Admin
Administrator
Administrator

Custom query is not available when using Amazon Athena Connector. Instead, you can try ODBC connector to connect to Amazon Athena and then you will have an option to write your custom query in advance options. I hope this answers your question.

 

Thanks.

KremenaK
Frequent Visitor

Hi, @edhans! Yes, I had tried Power Query beforehand and the filtering didn't reduce the dataset by much, the pivoting didn't work either (it was taking forever without result). Finally I left it spinning to import the dataset (with some filters and reduced number of columns) overnight and the task was completed (to my surprise!) - there were more than 105M rows! After inspecting the data it turned out there were about 85% cost items in the range -0.01 to 0.01. So after filtering those out in Power Query the data load time was siginificantly reduced - to 1.5 hr. Which is still way slower than DirectQuery (which loads in about 30s and updates visuals in 10s), but maybe the performance of Import Data will get better after publishing to the Power BI Service.

KremenaK
Frequent Visitor

Thank you, @edhans. Now I am connecting as Direct Query picking only the table columns and year(s) that I need and am able to compile some reports and visualizations. It's a bit slow, but workable. Thanks again

Hi,

 

Can you please provide me the steps where exactly you have writted the QRY (direct qry) for Athena  tables ? I feel to fire the SQL , some pre set up connection string needs to be written , which I am not able to do .

 

Thanks

Sanjoy

When you connect to Athena via ODBC driver you get the option to write a SQL query to limit what you pull into Power BI:

KremenaK_0-1702300586725.png

 

Another option would be to skip this step and in Power Query select the columns you need, filter data, do transformations, etc.
Hope this helps!

Yeah, DirectQuery is a special use case and can be very slow.

 

Did you try using Power Query? I am not sure if Athena is supported with folding, but if your first few steps are removing columns, renaming columns, most filtering, Power Query will create the SQL query to send back and let you get a nice clean import.

This works fantastic with SQL Server and many other databases. Just not sure about Athena.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
edhans
Super User
Super User

There is no place to do it per Using the Amazon Athena Power BI connector - Amazon Athena
You need to have a view created on Athena that limits the data as desired, then connect to that.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

I do not see any views in Athena (using the Simba Athena connector), only the tables. How do I get a list of the queries I have created>

 

Thanks.

Hav you got the solution for custom query in power bi using amazon athena

I am removing columns and filtering in Power Query and then loading the data via DirectQuery.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors