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

I am getting an empty table from Source after which when I try to expand a column am getting error

Hi

When I have atleast 1 record in an table the expand author  functionality is working fine. But If i get an empty table from source I am getting an error message "The Column Author of the table was not found".

NithyaKB_0-1631847717283.png

In the above image the table is empty from Source , When I try for expand author column for each books.

NithyaKB_1-1631847832797.png

Below is the code for reference

Source = lists/getbytitle( list name)/select id, books,author/Title&Expand = "Author",

"Added Custom" = Table.Add Column(Source , "Title" , each "Shakespeare")

"Expanded Author" = Table.ExpandRecordColumn(#"Added Custom" , "Author",{"Title"},{"Author"})

in

#"Expanded Author"

 

Is there anyway even if the table is empty it should expand author column along with all the columns specified in Source ?

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

Hi @NithyaKB ,

This problem seems to be caused by the absence of source table data information, resulting in an error in expand columns due to the Author column not being found. Please update the applied codes in your Advanced Editor as below and check whether it can work:

let
  Source = lists/getbytitle( list name)/select id, books,author/Title&Expand = "Author",                                                                               
  CheckEmpty = 
    if Table.IsEmpty(Source) then
      #table(type table [Author = [Author = any]], {})
    else
      Source, 
  #"Added Custom" = Table.AddColumn(CheckEmpty, "Title", each "Shakespeare"), 
  #"Expanded Author" = Table.ExpandRecordColumn(#"Added Custom", "Author", {"Title"}, {"Author"})
in
  #"Expanded Author"

If the above one is not working for your scenario, please share some sample data in your source table when there is some data in it. Later we will provide you a suitable solution base on your shared information. Thank you.

Best Regards

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

View solution in original post

5 REPLIES 5
v-yiruan-msft
Community Support
Community Support

Hi @NithyaKB ,

This problem seems to be caused by the absence of source table data information, resulting in an error in expand columns due to the Author column not being found. Please update the applied codes in your Advanced Editor as below and check whether it can work:

let
  Source = lists/getbytitle( list name)/select id, books,author/Title&Expand = "Author",                                                                               
  CheckEmpty = 
    if Table.IsEmpty(Source) then
      #table(type table [Author = [Author = any]], {})
    else
      Source, 
  #"Added Custom" = Table.AddColumn(CheckEmpty, "Title", each "Shakespeare"), 
  #"Expanded Author" = Table.ExpandRecordColumn(#"Added Custom", "Author", {"Title"}, {"Author"})
in
  #"Expanded Author"

If the above one is not working for your scenario, please share some sample data in your source table when there is some data in it. Later we will provide you a suitable solution base on your shared information. Thank you.

Best Regards

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

HI @v-yiruan-msft 
I need to give 3 columns in expand category . 
let
Source = lists/getbytitle( list name)/select id, books,author/Title&Expand = "Author","Books" , "Editors"
CheckEmpty =
if Table.IsEmpty(Source) then
#table(type table [Author = [Author = any]], {})
else
Source,
In this case sould you please tell me how to include 3 expanded columns(Author , Books,Editors) in check empty condition . In current condition it has only 1 expanded column that is Author.

Greg_Deckler
Super User
Super User

@NithyaKB Try:

Source = lists/getbytitle( list name)/select id, books,author/Title&Expand = "Author",
"Added Custom" = Table.Add Column(Source , "Title" , each "Shakespeare")
"Expanded Author" = if #"Added Custom" = null then #"Added Custom" else Table.ExpandRecordColumn(#"Added Custom" , "Author",{"Title"},{"Author"})
in
#"Expanded Author"

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

@Greg_Deckler 

I tried the below query as suggested .But still facing same issue.

NithyaKB_0-1631851061149.png

Please find below the screenshot of error message.

NithyaKB_1-1631851109208.png

 

@Greg_Deckler 

Can you suggest how to get the multiple columns

Source = lists/getbytitle( list name)/select id, books,author/Title&Expand = "Author",
"Added Custom" = Table.Add Column(Source , "Title" , each "Shakespeare")
"Expanded Author" = if #"Added Custom" = null then #"Added Custom" else Table.ExpandRecordColumn(#"Added Custom" , "Author",{"Title"},{"Author"})
in
#"Expanded Author"

(id , books ,authors) , If these columns are emoty then it should return empty tables. 

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.

Top Kudoed Authors