cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Andrew_lu1933
New Member

How to set var to select column name?

in power query, if I want to operate one column, we will  use _[columnName].

but if I want operate many column, I want use List.Transform({columnName1, columaname2},(t)=> operate(Table, [t]).

how to pass columnName var to operator this column?

4 REPLIES 4
wdx223_Daniel
Super User
Super User

List.Transform({Column1,Column2},each List.Sum(Table.Column(tbl,_)))

watkinnc
Super User
Super User

You can try

 

each (row)=> List.Tranform({row[Column1], row[Column2]}=> operate(Table, [t]))

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

[t]  , the t is only as a str, not as a var.

Vijay_A_Verma
Super User
Super User

If you can explain what exactly you are trying to do, then experts here can suggest the right solution. 

When you are doing List.Transform({columnName1, columaname2},(t)=>, it is t which contains columnName1 & 2 one by one and whatever you are operating on t will be applicable on columnName1 & 2.

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.

Top Solution Authors
Top Kudoed Authors