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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
siva_powerbi
Helper IV
Helper IV

Error while saving Power Query editor when expression.evaluate is used

Hello Experts.

 

I am using Expression.Evaluate to run a step in power query, So I have added #shared along with the function to evaluate the functions, Everthing is working fine but problem is I am unable to save the Query Editor or report because of below Error.

 

Failed to save modifications to the server. Error returned: 'Expression in partition 'Sorting Columns-94311d0d-b0e4-49cd-baf6-601b7ef667c9' in table 'Sorting Columns' references an entity that is not supported. One example of unsupported entity is the function '#shared'. '.

 

Code:

 

let
Source = Excel.Workbook(File.Contents("C:\Users\Desktop\Power BI\test1.xlsx"), null, true),
Sheet2_Sheet = Source{[Item="Sheet2",Kind="Sheet"]}[Data],
PromotedHeaders = Table.PromoteHeaders(Sheet2_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(PromotedHeaders,{{"Test1", type text}, {"Test2", Int64.Type}, {"Test3", Int64.Type}, {"Test4", Int64.Type}}),
#"Col Names_Sort" = Table.ColumnNames(#"Changed Type"),
#"Generate" = List.Generate(() => [i=-1,x= Table.FromList(#"Col Names_Sort",Splitter.SplitByNothing())],
each [i]<List.Count(#"Col Names_Sort"),
each [
// x={i},
i=[i]+1,
p=Expression.Evaluate(
"Table.RowCount(Table.Distinct(Table.FromList(#"&"""Sheet2 (2)"""&"["&#"Col Names_Sort"{i}&"],Splitter.SplitByNothing(), null, null, ExtraValues.Error)))"
,#shared),
q=#"Col Names_Sort"{i},
x = Text.Combine({Number.ToText(p),q},", ")
//y={i}

],
each [x]),
#"Remove_1stRow" = Table.SplitColumn(Table.RemoveFirstN(Table.FromList(#"Generate",Splitter.SplitByNothing()),1),"Column1",Splitter.SplitTextByDelimiter(", ")),
#"Sort_Col" = Table.Sort(#"Remove_1stRow",{"Column1.1",Order.Descending}),
#"Renamed Columns" = Table.RenameColumns(Sort_Col,{{"Column1.1", "DCount"}, {"Column1.2", "Column Name"}})
in
#"Renamed Columns"

 

Not Sure how to resolve.

 

Any help is Appretiated.

 

Thanks

Siva

1 REPLY 1
v-xuding-msft
Community Support
Community Support

Hi @siva_powerbi ,

 

This function is not fully supported yet. You could vote up the idea to get it implemented quickly.

 

provide full support for Expression.Evaluate with #shared 

 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.