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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Retrieve certain number of rows per category

Hello all!

I have a data source that's a MySQL DB. Within that is a huge table (+10million rows) which I don't wish to refresh in its entirety everytime.

Keeping the first rows is simple, but how do I keep the first rows for each distinct category in the table?

 

In my case the data is identified by customer name, so how would I got about writing a query to retrieve the first 10,000 rows for each customer?

 

Thanks!

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@Anonymous,

Do you want to write specific query to get data when importing data from MySQL database into Power BI Desktop? If so, the blogs below describe that how to  select first N rows for each category using MySQL query. You can refer to them.

http://www.sqlines.com/mysql/how-to/get_top_n_each_group
http://samalpramod.blogspot.com/2014/12/getting-top-n-rows-by-each-category-in.html


Regards,

Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yuezhe-msft
Employee
Employee

@Anonymous,

Do you want to write specific query to get data when importing data from MySQL database into Power BI Desktop? If so, the blogs below describe that how to  select first N rows for each category using MySQL query. You can refer to them.

http://www.sqlines.com/mysql/how-to/get_top_n_each_group
http://samalpramod.blogspot.com/2014/12/getting-top-n-rows-by-each-category-in.html


Regards,

Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

That helped thanks.

 

I now have a new problem, which is that some of the columns are titled with a dot in their name

 

e.g. customer.name

 

The query refuses to accept these, square brackets and backticks don't help either. Any ideas?

Anonymous
Not applicable

Got it!

 

Single quotes ' around a column name with a dot will allow the query to be accepted.

 

For reference, if you have a DB with an invalid character (in the From part), then you need to encase it in backticks

@Anonymous,

Please open a new thread about the new issue.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors