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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

From Web Connector - How can I add current date to a query?

I have a report that extracts data from Mixpanel.  Mixpanel allows you to call an API with from/to date parameters.

 

I can extract data if I hard code the dates, but I want to be able to set the to_date to be today.

 

Query that works:

https:// <<secret_key>> @mixpanel.com/api/2.0/segmentation?from_date=2020-04-01&to_date=2020-04-28&e... of Us Marketing Landing Page

 

I tried this, but I'm getting an error with the format:

https://<<secret_key>> @mixpanel.com/api/2.0/segmentation?from_date=2020-04-01&to_date=`date +%y/%m/%d`&event=All of Us Marketing Landing Page

 

Power BI Desktop.png

I can't find anything in the documentation that supports this.  Any help would be appreciated.

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could use dynamic parameter to define your to_date. You need to set it in the query editor.

Here is the m query for your reference.

let
    localdate = Text.Format("#{0}-#{1}-#{2}",{Date.Year(DateTime.LocalNow()),Date.Month(DateTime.LocalNow()),Date.Day(DateTime.LocalNow())}),
    test=Json.Document(Web.Contents("https:// <<secret_key>> @mixpanel.com/api/2.0/segmentation?from_date=2020-04-01&to_date="&localdate&"&event=All of Us Marketing Landing Page"))
in
    Source

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

2 REPLIES 2
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could use dynamic parameter to define your to_date. You need to set it in the query editor.

Here is the m query for your reference.

let
    localdate = Text.Format("#{0}-#{1}-#{2}",{Date.Year(DateTime.LocalNow()),Date.Month(DateTime.LocalNow()),Date.Day(DateTime.LocalNow())}),
    test=Json.Document(Web.Contents("https:// <<secret_key>> @mixpanel.com/api/2.0/segmentation?from_date=2020-04-01&to_date="&localdate&"&event=All of Us Marketing Landing Page"))
in
    Source

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Anonymous
Not applicable

Thanks, using a dynamic parameter was the way to go.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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