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
Coopa_kid
Frequent Visitor

Cannot Expand Null List

I am getting heavily nested data from an api and need to expand all the columns. I followed this guide to stop creating new rows from expanding them and it worked well. The problem is some of the lists are null. They all appear as type List after zipping, but some have null values. In the editor I can expand them to records and then expand them further, but for some reason when I try to load the data into the report I get the below error whenever I try to change to records and load in the report. 

 

OLE DB or ODBC error: [Expression.Error] We cannot convert the value null to type List..

 

Optimally I would delete the rows with null values since they have no data, but I cannot figure out how to tell if one of the list items contains no data and delete it. 

 

Function below (It's a closed API):

let
Source = Json.Document(Web.Contents(www.API.com, [Headers=[Authorization="Token"]])),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"webPathId", "milestones"}, {"Column1.webPathId", "Column1.milestones"}),
#"Expanded Column1.milestones" = Table.ExpandListColumn(#"Expanded Column1", "Column1.milestones"),
#"Expanded Column1.milestones1" = Table.ExpandRecordColumn(#"Expanded Column1.milestones", "Column1.milestones", {"networkTiming", "serverTiming", "browserTiming", "apdexScore", "basePageSize", "statusCode"}, {"networkTiming", "serverTiming", "browserTiming", "apdexScore", "basePageSize", "statusCode"}),
#"Merged Columns" = Table.CombineColumns(#"Expanded Column1.milestones1",{"networkTiming", "serverTiming", "browserTiming", "apdexScore", "basePageSize", "statusCode"}, each List.Transform(List.Zip(_), each Record.FromList(_,{"networkTiming", "serverTiming", "browserTiming", "apdexScore", "basePageSize", "statusCode"})),"Merged"),
#"Expanded Merged" = Table.ExpandListColumn(#"Merged Columns", "Merged")
in
#"Expanded Merged"

 

1 ACCEPTED SOLUTION

Well, that was it! Finally got it to load. Thanks for the help @Greg_Deckler . Even though that wasn't the answer it was the only thing that allowed me to find the issue! Thanks!

View solution in original post

9 REPLIES 9
Greg_Deckler
Super User
Super User

I had a similar issue to this, I will try to dig up my solution. But, in essence, what I did was make the expansion/conversion conditional by throwing in an if then else statemetn into the each clause so if null then null otherwise convert


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks @Greg_Deckler, I've been having issues even telling whether a list is null since it's nested. I'm fairly new to dax though, so I may be doing something wrong. It's been difficult to track down the issue since it only occurs when I try to load it in the report. It's strange that it works fine in the editor. 

Here is a simple example.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWAhNGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Column1] = "" then 0 else Number.FromText([Column1]))
in
    #"Added Custom"

 

You could create a new column where you check if the other column is null and if so return null or "", etc. Otherwise, (else) you would just plug in your List expansion code. @Coopa_kid  


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Well that shows how familiar I am with this, Power Query then.

 

I'm still a little lost. I do see nulls in the editor and it is transforming them fine, which is the really weird part. 

 

I understand in principle what you're saying, and that sounds like a good plan, but I'm unsure how to do it in this example. In short, I have a list that is transformed into 4 lists of values. I then zip those up. Prior to zipping some of the lists were null, but they still showed. Once zipped now the zip is null since it removes that top layer of lists. Now I have some that are zipped lists of lists and some that are null. I try to convert those lists to records so they can be expanded and that's where it fails. I need to be able to see if they are null before and delete them. I have tried List.IsEmpty(), but that doesn't seem to work

 

I tried the snippet you sent to create a new column and they all came back as not null. Probably since they are a list

but..... I decided to use list.IsEmpty() with creating a new column and I found my issue. It may not have been the nulls after all.... It seems two of the zipped lists have an error in them. It must have occurred in an earlier step, but I never saw it since it didn't show as errored at the top and I never looked inside all the lists. I'm gonna do some digging

So the error occurred before zipping. I never saw it since it was all zipped up, but some of the lists were null before zipping. As in they themselves are null, not filled with nulls. So now I need to remove those before zipping. Any tips? 

Well, that was it! Finally got it to load. Thanks for the help @Greg_Deckler . Even though that wasn't the answer it was the only thing that allowed me to find the issue! Thanks!

Well glad we got there!! 🙂

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Oh, this is not DAX, this is Power Query and the error you are getting is a Power Query error during data load. It is likely not happening while you are in the editor because the first rows do not exhibit a null but later rows do. Let me see if I can get you an example.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.