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
jbrown184
Helper I
Helper I

Issues using custom dates for API

Hey everyone!,

 

I am trying to add in custom dates in an API URL. Example: I am converting 

startDate=2024-12-01&endDate=2025-12-05

to

startDate=[Current Date]&endDate=[Start Date].

Here is what it looks like.

jbrown184_0-1733417662357.png

 

 

4 REPLIES 4
Anonymous
Not applicable

Hi @jbrown184 

Did the solutions Omid_Motamedise , ZhangKun  and lbendlin  offered help you solve the problem, if them helps you can consider to accept them as solutions so that more user can refer to, or if you have other problems you can offer some infomrmation so that can provide more suggestion for you.

 

Best Regards!

Yolo Zhu

 

Omid_Motamedise
Super User
Super User

use the below formual

 

="startDate="&Text.From([Current Date])&"&endDate="&Text.From([Start Date])

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
ZhangKun
Super User
Super User

If you just want to solve the problem, you only need to concatenate the strings:

 

"...&startDate=" & [Current Date] & "&endDate=" & [Start Date]

 

But for this slightly complex problem, decoupling should usually be done, that is, splitting the complex function into several small functions. Especially if there is some sensitive information in your problem.

For example, the following method first creates a function:

 

// just an example
(s, e) =>
// https://restapi.amap.com/v3/geocode/geo?startDate=xxx&endDate=yyyy&grouping[]=a,b,c
Web.Contents(
    "https://restapi.amap.com", 
    [
        Query=[
            startDate = s, 
			endDate = e, 
			// because record don't support multiple same field names, the following method is used.
			// most servers support this method to pass multiple parameters with the same field name.
			#"grouping[]" = "a,b,c"
        ], 
        RelativePath="/v3/geocode/geo"
    ]
	// other code
)

 

Then call the function fx in Table.AddColumn:

 

Table.AddColumn(tbl, "custom", each fx([Start Date], [Current Date]))

 

You can also pass other things like the table name (or perhaps other things like the dataset) as parameters, so that it is a generic function instead of having to rewrite it every time you use it.
lbendlin
Super User
Super User

Please follow the documentation. Use RelativePath and Query parameters. https://learn.microsoft.com/en-us/powerquery-m/web-contents#example-1

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.