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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Eleanor24
Frequent Visitor

Refresh M Query - Correct Syntax For Dates

I am exporting all data from a log table in App Insights to Power BI as an M query. I want to create a semantic model or dataflow in Power BI that allows me to refresh the data to retrieve the latest values from all columns in the table. I have been able to export the data and add it as a blank query in the advanced editor, but I am struggling with the correct way to use the timestamp field in the table to write in the date range in the M query.

Essentially, I'm hoping to (upon retrieval of new data) to have the query pull data from the last 90 days of data up to the current date/time. I am currently just getting the date range I set when querying the log data in App Insights before exporting the query. I only need the events and timestamps in the table to create some basic funnels, so I think defining the date correctly to get new data is the only hurdle.

 

AI.png

For example, in SQL I would write it as: 

timestamp>=DATEADD(DAY,-90,CONVERT(date,GETDATE())) 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Eleanor24 ,

Please try this:

let
    Source = YourTableName, // Replace with your actual data source
    CurrentDate = DateTime.From(DateTime.Date((DateTime.LocalNow()))),
    StartDate = DateTime.From((Date.AddDays(CurrentDate, -90))),
    FilteredRows = Table.SelectRows(Source, each [datetime] >= StartDate and [datetime] < Date.AddDays(CurrentDate,1))
in
    FilteredRows

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Eleanor24 ,

Please try this:

let
    Source = YourTableName, // Replace with your actual data source
    CurrentDate = DateTime.From(DateTime.Date((DateTime.LocalNow()))),
    StartDate = DateTime.From((Date.AddDays(CurrentDate, -90))),
    FilteredRows = Table.SelectRows(Source, each [datetime] >= StartDate and [datetime] < Date.AddDays(CurrentDate,1))
in
    FilteredRows

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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