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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Amar-Agnihotri
Resolver I
Resolver I

Want dynamic dates in EventActivityLog function of PBI RESTAPI

Hi
I am using custom connector which i downloaded from this github link - 
 
 
This custom connector is using Power BI REST APis internally and loading all the artifacts from the BI service in the form of table as below 
image.png
 
It will load all the artifacts in the form of tables as 
image(1).png
 
But User Activity data is not directly available as a table -
To get USer Activity data it is providing an "EvenActivityLog" function which ask for start date and end date and when you will put dates over there it will get the data as table
 
image(2).png

 

Now i loaded last 60 days data by giving hard coded date range -
image(3).png

 

Now i want to make these dates dynamic so that i don't have to change the dates every time -
 
Right now it is as given in the M code - 
 
image(4).png

 

I want to set End Date = Current Date
and Start Date = Current Date - 90 days
 
so that for every refresh on everyday only the last 90 days user activity data will be loaded. 
 
I tried to use Date.From(DateTime.LocalNow()) in place of 
#date(2022, 2, 10)), but that was not working throwing error every time because what i believe that we don't know the function definition so we can't say the format and datatype it is using behind the scenes.
 
I tried using parameters but don't know where to put those because the function is picking up date from hard coded from the calendar as
 

 

image(5).png

 Now i am stuck here. Please help me to make this date dynamic.  you can download the custom connector .mez file from the above GitHub link  so that you can also check all the process using that connector. The process to use this connector is described in the github link given above.

 
 
Thanks 

 

1 REPLY 1
lbendlin
Super User
Super User

 

I tried to use Date.From(DateTime.LocalNow()) in place of 
#date(2022, 2, 10)), but that was not working throwing error every time because what i believe that we don't know the function definition so we can't say the format and datatype it is using behind the scenes.

 

 

That doesn't sound right. Your timestamps need to be in ISO8601 format. Try this

 

 

= #table({"Start Date","End Date"},{{DateTime.ToText(DateTime.LocalNow()-#duration(90,0,0,0),"yyyy-MM-ddT00:00:00.000"),DateTime.ToText(DateTime.LocalNow(),"yyyy-MM-ddT23:59:59.999")}})

 

lbendlin_0-1644789351030.png

 

 

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.