Forum Discussion

masplin's avatar
masplin
Icon for Power Participant rankPower Participant
6 years ago
Solved

Strange circular dependency maybe needs row idnefier

I have an exisitng model which was built very inefficiently by pulling in a whole SQL table then slowly removing different columns. It works fine, but getting slow. I thoguht it woudl be an easy job ...
  • masplin's avatar
    masplin
    6 years ago

    yes this is all done through Power Query.

     

    I think I found the answer which is quite bizarre.

     

    In my original table the first column say was [Customer No_] in the database. I then renamed this to [Customer No] in PQ.  On upload this is the first column in Data View and I assume Power BI treats this as the row identifier? 

     

    Whne i changed the source query to SQL I thought I would do the renamingon import so wrote

    [Customer No_] AS [Customer No]

     

    However Power Bi thinks this is a new column and put it at the end of the data view like it would do if you ammended the Power Query and added a column or if you add calcuated columns.  This is completely mad as the name of the column is identical and created in the source step.  The problem is now my first column in data view is a non-unique column so lots of my calculated columns now have circular errors.  This is not fixable as Power BI does not have the abilty to specifc a column as the row identifier.

     

    Luckily I found the solution. DO NOT rename an SQL column in the SQL SELECT statement. If you SELECT is as [Customer No_] and do theremane in Power Query it sees this as the same column already exisitng and leaves it at the front of Data view. All the formulae work fine.   Probably it's just the column that is the unique row identifier that must not be renamed in SQL.

     

    Took me 3 days to work this out.  Really stupid bug.