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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors