Forum Discussion
rssilvaba
6 years agoResolver II
Empty sharepoint list does not load the columns.
Hi All, I just realized that one of the report we designed has a sharepoint list data source that can be emptied. Now the dataset can't be refreshed and the measures from that respective table do...
Izs
3 years agoFrequent Visitor
Hi, I solve my problem using the above method by checking if the table is empty and manually filling the columns but only filling in the value for the relationship column and others blank (). That column is also the only selected column that I will use in my report and make sure the column name is the same as the real column to avoid any errors.
Here is my sample M code in Power Query,
let
Source = SharePoint.Tables("https://e.sharepoint.com/sites/a/ICT", [Implementation=null, ApiVersion=15]),
//Define the list ID
#"SPSource" = Source{[Id="SPSource"]}[Items],
//Check if Source is an empty table
//If yes, returns a table with a single row/column "Id=null"
//If not, does the rest of the code
CheckEmpty = if Table.IsEmpty(#"SPSource")
then
#table(
//type table [Id = number],
{
"clm_Title", // First Column Field Name
"clm_StatusOrder" ,
"WebUrl",
"clm_RequestDate"
},
{
{
"", // First Column Field Value
"",
"https://e.sharepoint.com/sites/a/ICT", // For relationship
""
}
}
)
else (
let
#"Added Custom" = Table.AddColumn(#"53507bbf-1338-4978-80aa-193a7408b62f", "WebUrl", each "https://e.sharepoint.com/sites/a/ICT"),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"StatusOrder", Int64.Type}, {"ChangeImpactOrder", Int64.Type}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Id", "clm_Id"}, {"Title", "clm_Title"}, {"Priority", "clm_Priority"}, {"Status", "clm_Status"}, {"StatusOrder", "clm_StatusOrder"}, {"ChangeImpactOrder", "clm_ChangeImpactOrder"}}),
#"Expanded Author" = Table.ExpandRecordColumn(#"Renamed Columns", "Author", {"FirstName"}, {"Author.FirstName"}),
#"Expanded ChangeInitiator" = Table.ExpandRecordColumn(#"Expanded Author", "ChangeInitiator", {"FirstName"}, {"ChangeInitiator.FirstName"}),
#"Renamed Columns1" = Table.RenameColumns(#"Expanded ChangeInitiator",{{"Author.FirstName", "clm_Author"}, {"ChangeInitiator.FirstName", "clm_Initiator"}, {"RequestDate", "clm_RequestDate"}})
in
#"Renamed Columns1"
)
in
CheckEmpty
Hope it can help others.