Forum Discussion

Mr_Glister's avatar
Mr_Glister
Advocate II
2 years ago
Solved

Only show subset/sample of data with Direct Query

Hi, I have a table with many millions of Image URLs in it, and connect to it through Direct Query.  We can assume the columns in the table are COUNTRY / STATE / WAREHOUSE / DATE / VALUE / IMAGE URL...
  • Mr_Glister's avatar
    2 years ago

    I realized instead of doing something complicated in PowerBI it makes much more sense to do something slightly more complicated directly in the SQL statement.

     

    For anybody else with the same problem, here is what was the perfect solution for me:

     

    select * from prod.sales
    where 
         invoice_date > current_timestamp - interval '30 days'
    qualify
         row_number() over(partition by country, state, warehouse, date order by value DESC) <=10