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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.