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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
StefanoT1982
Regular Visitor

Evaluating a column through steps without hardcoding the steps' names

Assume I have a simple table with 2 steps:

let

    Step1 = #table (type table[Names = Text.Type, Money = Int64.Type], {{"John", 1}, {"Jack", 2},{"Mary", 4} }),

    Step2 = Table.Skip(Step1,1)

   

in

Step2

 

If I want to check the evolution of the total sum of the “money” column I can create a record like this:

 

  CheckManual = [

        Step1 = List.Sum(Table.Column(Step1, "Money")),

        Step2 = List.Sum(Table.Column(Step2, "Money"))

        ]

But this hard codes the previous steps names. Is there a way to work this around?

 

Also something that would required a simple copy paste in the advanced editors of the steps I want to evaluate would be fine.

Eg I tried to transform the steps names into a list like in the example below, but could do a similar thing with the “money” column through the steps…

 

  StepsNames = Record.FieldNames([

        Step1 = #table (type table[Names = Text.Type, Money = Int64.Type], {{"John", 1}, {"Jack", 2},{"Mary", 4} }),

        Step2 = Table.Skip(Step1,1)

        ])

 

Thanks!

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

let
    steps = 
        [
            Step1 = #table (type table[Names = Text.Type, Money = Int64.Type], {{"John", 1}, {"Jack", 2},{"Mary", 4} }),
            Step2 = Table.Skip(Step1,1)
        ],
    money_evolution = ((fields) => Record.FromList(List.Transform(fields, (x) => List.Sum(Record.Field(steps, x)[Money])), fields))(Record.FieldNames(steps))
   
in
    money_evolution

View solution in original post

3 REPLIES 3
AlienSx
Super User
Super User

let
    steps = 
        [
            Step1 = #table (type table[Names = Text.Type, Money = Int64.Type], {{"John", 1}, {"Jack", 2},{"Mary", 4} }),
            Step2 = Table.Skip(Step1,1)
        ],
    money_evolution = ((fields) => Record.FromList(List.Transform(fields, (x) => List.Sum(Record.Field(steps, x)[Money])), fields))(Record.FieldNames(steps))
   
in
    money_evolution

that's great! would you mind explaining how it works? I'm little familiar with the "=>" function syntax

"steps" is record. 

Record.FieldNames(steps)

reads it's fields' names and gets list of names (of steps). 

List.Transform

 goes over the list, picks up every other (step) name and calculates List.Sum of Money column values. 

Record.FromList

folds the results into another record with steps names and Money totals. 

M is functional language so get used to functions syntax and usage.  

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.