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

API query error "Cannot convert the value false to Type list".

Hello, everyone.

 

I am new to API calls in Power Query and got this code from a colleague who is unavailable for some time. To me this is quite complex M-code that I am having a hard time debugging. It is probably unsolvable with the provided information, but I am giving it a shot.

 

The error code we are getting is 

 

Petsnell_0-1668168911419.png

 

 

let

  startDate = DateTimeZone.FromText(FromDate),

  endDate = DateTimeZone.FromText(ToDate),

  #"Api url" = "",

  #"Raw data from api"  = Json.Document(Web.Contents(#"Api url",

    [

      Headers = [#"Content-Type"="application/json",#"Authorization"="Bearer "&AuthToken&"" ]

    ])),

 

  GetChunk = (ChunkFrom as datetimezone, ChunkTo as datetimezone) =>

    #"Api url" = ApiUrl ="&DateTimeZone.ToText(ChunkFrom, "yyyy-MM-ddTHH:mm:ssZ")&"&toDate="&DateTimeZone.ToText(ChunkTo, "yyyy-MM-ddTHH:mm:ssZ"),

   

  GetChunks = (chunkStartDate as datetimezone) =>

    let chunkEndDate = Date.AddDays(chunkStartDate, 14),

    actualStartDateTime =  if chunkStartDate = startDate then chunkStartDate else chunkStartDate + #duration(0,0,0,1),

    actualEndDateTime =  if (chunkEndDate > endDate) then endDate else chunkEndDate

    in

      GetChunk(actualStartDateTime, actualEndDateTime),

 

ExpandResult = (result as list) =>

    if List.Count(result) < 1

      then

        #table({"StartDateTime"},{{endDate}})

      else

        let

          table_converted = Table.FromList(result, Splitter.SplitByNothing(), null, null, ExtraValues.Error),

          expanded = Table.ExpandRecordColumn(table_converted, "Column1", {"id", "userId", "externalId"})

        in

          Table.TransformColumnTypes(expanded,{{"StartDateTime", type datetimezone}}),

 

#"Chunks" = List.Generate( () => GetChunks(startDate), (result) => List.Count(result) > 1, (result) => GetChunks(List.Max(ExpandResult(result)[StartDateTime])), (result) => ExpandResult(result) ),

  result = Table.Combine( #"Chunks")

in

  #"Chunks"

3 REPLIES 3
Petsnell
Helper I
Helper I

After isolating the code it seems the issue is related to 

 

  GetChunk = (ChunkFrom as datetimezone, ChunkTo as datetimezone) =>

    #"Api url" = ApiUrl ="&DateTimeZone.ToText(ChunkFrom, "yyyy-MM-ddTHH:mm:ssZ")&"&toDate="&DateTimeZone.ToText(ChunkTo, "yyyy-MM-ddTHH:mm:ssZ")

 

as it returns "False", and not a list. 

Hi @Petsnell ,

 

My initial guess is that you've got extra equals signs in there that shoudn't be. These are the only sections where Power Query can resolve to a boolean output.

 

BA_Pete_0-1668174144738.png

 

My second guess is that it should look something like this instead:

 

GetChunk = (ChunkFrom as datetimezone, ChunkTo as datetimezone) =>
#"Api url" =
ApiUrl
    & "DateTimeZone.ToText(ChunkFrom, "yyyy-MM-ddTHH:mm:ssZ")"
    & "DateTimeZone.ToText(ChunkTo, "yyyy-MM-ddTHH:mm:ssZ")"

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Much appreciated, BA_Pete. From what I gather, the issue did not seem to be the equals signs but rather the location of the API-call. Instead of iterating the function with the new variable name it reiterated the renaming process. 

Helpful resources

Announcements
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.

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.