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
ejwwelshboy
Regular Visitor

Only showing the last X number of readings with a Direct Query connection

Hello, I have some data in power BI that is connected to a SQL database via a Direct Query connection. I am having issues trying to only show the last X amount of readings, or reading over the last X amount of days. I tried using the Age function built into Power BI, but it would not work with a Direct Query connection. The time data that I am receiving is in the following format. 

6/17/2017 3:05:00 PM

Any advice on how to limit the readings shown on my graphs would be greatly appreciated. 

1 ACCEPTED SOLUTION

Thanks for the help @MFelix.

I was able to figure out a solution to my problem. I was able to use a SQL statement to only bring in the last 24 hours of data into Power BI.

The SQL statement that I used was

 

select Name, location, myDate from myTable where myDate between DATEADD(hh, -24, GETDATE()) and GETDATE()

 

 

View solution in original post

4 REPLIES 4
MFelix
Super User
Super User

Hi @ejwwelshboy,

 

If you want to limit the amount of data you are receiving from SQL try to use a parameter to pass along the number of dsays you want to deduct from your query, check this page on parameters for power bi and you can take some ideas.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix,

I don't think ising the parameters function would work in my case becase while I can use it to only show certain days I have no way to only show the last 2 days of data that is constantly being refreshed using the direct query connection. 

Thanks,

Ejwwelshboy

Hi @ejwwelshboy,,

 

Can you please explain and show some example of what you want.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Thanks for the help @MFelix.

I was able to figure out a solution to my problem. I was able to use a SQL statement to only bring in the last 24 hours of data into Power BI.

The SQL statement that I used was

 

select Name, location, myDate from myTable where myDate between DATEADD(hh, -24, GETDATE()) and GETDATE()

 

 

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.