Search code examples
powerbipowerbi-desktopm

Power BI Query Editor - Inserting Rows to the Bottom of a Table


I have a table that looks like this in Power BI:

CourseID      Course
1             Math
2             Cooking
3             English
4             Spanish

I want to insert a row at the bottom that looks like this:

-1            null

I looked at the Microsoft Documentation, but it's not very helpful. Any suggestions?


Solution

  • Figured out what I was doing wrong.

    Let's say I wanted to insert a row, at top of a table, named Courses.

    The M query would look like this

    #Insert Row = Table.InsertRows(#PreviousStepName,0,{[CourseID=-1,Course=null]})
    

    Was not able to get it working if the column name had a space in it, but for best practices, you shouldn't have columns with spaces in the name anyway.