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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Create a dynamic value for Json.Document function

Hi All,

 

I'm using the function Json.Document to get data from an API. Below is the an example of the Json.Document value:

 

Json.Document(Web.Contents("https://url.com/site/222222/energyDetails?xxx&startTime=2022-07-21%2011:00:00&endTime=2022-08-26%2013:00:00&api_key=xxx"))

 

 

I would like to change the startTime and the endTime value dynamically with values coming from another table. Is it possible ?

Maybe something like this:

 

Json.Document(Web.Contents("https://url.com/site/22222/dateDetails?xxx&startTime=2022-07-21%2011:00:00&endTime="#Table1[endTime]"&api_key=xxxx"))

 

 

Many thanks in advance for your help.

1 ACCEPTED SOLUTION

Welcome to the wonderful world of the formula firewall.  Happy reading.

Behind the scenes of the Data Privacy Firewall - Power Query | Microsoft Docs

 

Inline your queries if possible.

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi,

 

thanks for your recommandation.

After reading the Query option for the Web.Contents(), I used the web.contents like below:

= Json.Document(
        Web.Contents(
            "https://url.com/site/222222",
            [
                RelativePath="energyDetails",
                Query=
                [
                    grid="XXX",
                    startTime=DateTime.ToText(#"Site Data - Start and End Date"[dataPeriod.startDate]),
                    endTime="2022-08-29 13:00:00",
                    api_key="xxx"
                ]
            ]
        )
    )

the options "startTime" and "endTime" are from another table "Site Data - Start and End Date" which contains two columns:

  • dataPeriod.startDate
  • dataPeriod.endDate

 

I got the the problem below when i'm executing the code above:

KLED_0-1661784440010.png

 

What's wrong with the startTime value ? how can I fix that ?

 

Thanks in advance for the help

Regards,

 

 

 

startTime=DateTime.ToText(#"Site Data - Start and End Date"[dataPeriod.startDate]){0}
Anonymous
Not applicable

Thanks @lbendlin for your feedback.

 

I still have the same error message after adding "{0}":

 

startTime=DateTime.ToText(#"Site Data - Start and End Date"[dataPeriod.startDate]){0}

 

 

I tried to added inside the DateTime.ToText() function and I got the error message as below :

 

startTime=DateTime.ToText(#"Site Data - Start and End Date"[dataPeriod.startDate]{0})

 

KLED_0-1661840349481.png

Any help ?

Welcome to the wonderful world of the formula firewall.  Happy reading.

Behind the scenes of the Data Privacy Firewall - Power Query | Microsoft Docs

 

Inline your queries if possible.

 

Anonymous
Not applicable

@lbendlin many thanks for your help 

lbendlin
Super User
Super User

read about the Query option for Web.Contents()

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.