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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live 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

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.