Forum Discussion

vojtechsima's avatar
vojtechsima
Super User
3 years ago
Solved

Inner function call cannot be saved in Power BI Dataflow

Hello, guys,

I have this function 

 

 

let
     ExpandIt = (TableToExpand as table, optional ColumnName as text) =>
     let
          ListAllColumns = Table.ColumnNames(TableToExpand),
          ColumnsTotal = Table.ColumnCount(TableToExpand),
          CurrentColumnIndex = if (ColumnName = null) then 0 else  List.PositionOf(ListAllColumns, ColumnName),
          CurrentColumnName = ListAllColumns{CurrentColumnIndex},
          CurrentColumnContent = Table.Column(TableToExpand, CurrentColumnName),
          IsExpandable = if List.IsEmpty(List.Distinct(List.Select(CurrentColumnContent, each _ is record))) then false else true,
          FieldsToExpand = if IsExpandable  then Record.FieldNames(List.First(List.Select(CurrentColumnContent, each _ is record))) else {},
          ColumnNewNames = List.Transform(FieldsToExpand, each  CurrentColumnName &"."& _),
          ExpandedTable = if IsExpandable  then Table.ExpandRecordColumn(TableToExpand, CurrentColumnName, FieldsToExpand, ColumnNewNames) else TableToExpand,
          NextColumnIndex = CurrentColumnIndex+1,
          NextColumnName = ListAllColumns{NextColumnIndex},
          OutputTable = if NextColumnIndex > ColumnsTotal-1 then ExpandedTable else _ExpandIt(ExpandedTable, NextColumnName)
     in
          OutputTable
in
     ExpandIt

 

 


For certain recent reasons I need to use PBI Dataflow, the connector is On-Premise Gateway.
This Function is it's own query, when I call this function in another query it works perfectly. However, this dataflow cannot be saved because I get this error:

The cycle is caused by function calling itself, however, that shouldn't be a problem since, the calling in my fact table works and this whole thing works also in Power BI DEsktop PQ.

The flow is "enhanced mode" in Power BI Premium capacity workspace.

I appretiate andy comment.

 
 
 
  • So, I fixed it by nesting the function inside my actual query, but... This is some weird behavior that only gives a headache, please could someone from Microsoft admins advise me on this, if this is a bug or a "feature", please?
    Then we can consider this thing "Solved".

     
     

2 Replies