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
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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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