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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
PBI_SG
Regular Visitor

Math Operations on Dynamic Table.SelectColumns

I am getting some dynamic column names from a table "Model_Workings" where the column names follow certain business specific criteria - (begin with "abc" and end with "def"). 

 

= Table.SelectColumns(
                                       Model_Workings,
                                       List.Select(
                                                           Table.ColumnNames(Model_Workings),
                                                            each Text.StartsWith(_,"abc") and Text.EndsWith(_,"def")
                                                       )
                                     ) + 1 

 

My need is to perform some math operations (as simple as +1 for purposes of an example) - and I run into an error that I am currently unable to work my way around - error details below

 

Expression.Error: We cannot apply operator + to types Table and Number.
Details:
Operator=+
Left=[Table]
Right=1



Please could I get some help on how to get around this issue?

 

Thanks in advance 🙂

1 ACCEPTED SOLUTION
smozgur
Helper I
Helper I

Try the following M Code.

 

let
    // Source data
    Model_Workings = Excel.CurrentWorkbook(){[Name="Model_Workings"]}[Content],

    // Filter columns
    Columns = List.Select(
                        Table.ColumnNames(Model_Workings),
                        each Text.StartsWith(_, "abc") or Text.EndsWith(_, "def")
                    ),
    // Perform math operation
    Result = Table.FromRecords(Table.TransformRows(Model_Workings,
            (row) => Record.TransformFields(row, List.Transform(
                    Columns, 
                    (fieldname) => {fieldname, each Record.Field(row, fieldname) + 1}
                ))))

in
    Result

View solution in original post

1 REPLY 1
smozgur
Helper I
Helper I

Try the following M Code.

 

let
    // Source data
    Model_Workings = Excel.CurrentWorkbook(){[Name="Model_Workings"]}[Content],

    // Filter columns
    Columns = List.Select(
                        Table.ColumnNames(Model_Workings),
                        each Text.StartsWith(_, "abc") or Text.EndsWith(_, "def")
                    ),
    // Perform math operation
    Result = Table.FromRecords(Table.TransformRows(Model_Workings,
            (row) => Record.TransformFields(row, List.Transform(
                    Columns, 
                    (fieldname) => {fieldname, each Record.Field(row, fieldname) + 1}
                ))))

in
    Result

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.