Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Power query - dynamic column type

Hi everyone   I'm got a really simple query but I'm struggling to change the type of specific columns. I built most of it through the UI. I basically want to change all columns to type number excep...
  • Anonymous's avatar
    Anonymous
    8 years ago

    I recommend reading up on Gil Raviv's 10 blogs on pitfalls of Query Editor.

     

    I think this blog in particular will be what you need to think about.

     

    To summarize, Table.ColumnNames(Table) will generate a list of column names.  Wrap that with a List.Count().  Now you know how many columns you have.  If that is stored a step, you have access to a variable with how many columns there are.  Now you can refer to columns by their 0-based index off of that variable.  I believe you can do a Replace Values step with that column index.

     

    Happy hunting!