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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
costic
Frequent Visitor

Power Query : Column as parameter

Hello,

 

There are some tips here that should have help me but i don't get how to use them, so i post my message :

1) i have a table of opportunities.

opportunitiesTable.PNG

2) in this table there are columns with lists of people

3) I extract the names in the list of people of a column to make a new one with the names (not a list)

=> I'd like to make a function with a column name as parameter to extract the names of any columns which contains lists of people

nestedPeople.PNG

for the moment, the following code is workin, but  :

let
    getPeople = (OpportunitesID) =>

    let
    //get all the list of opportunities in my site
        MyLists = let
        Source = SharePoint.Tables("https://mydomain.sharepoint.com/sites/mysite/", [Implementation="2.0", ViewMode="Default"]),
        opportunitesTable = Source{[Id="123456"]}[Items]
    in
        Source,
        opportunitesTable = MyLists{[Id="123456"]}[Items],
        //get the list of people in the column "People" for each rows
        getListOfPeople = opportunitesTable{[ID=OpportunitiesID]}[People], // I d like "People" being a parameter
        ListOfPeopleToTable = Table.FromList(getListOfPeople, Splitter.SplitByNothing(), nullnull, ExtraValues.Error),
        ExpandedCol = Table.ExpandRecordColumn(ListOfPeopleToTable, "Column1", {"lookupValue"}, {"Column1.lookupValue"}),
        Transform.ToQueryString = (table) => Text.RemoveRange(List.Accumulate(Table.ToList(ExpandedCol), "", (a, b) => a & ";" & Text.Replace(b, ",""=")), 01)
    in
        Transform.ToQueryString(ExpandedCol)
in
getPeople
 
 
____
i'd like to manage the case that there is no column/record. I tried to add a record "lookupValue" in the list (transformed into table), but i m not sure to do it well either...
 
thank you for help
1 ACCEPTED SOLUTION
costic
Frequent Visitor

Hey, i ll do that by sequences... for custom function for the moment.

View solution in original post

4 REPLIES 4
costic
Frequent Visitor

Hey, i ll do that by sequences... for custom function for the moment.

mahoneypat
Microsoft Employee
Microsoft Employee

Have you tried using the Table.Column function, which allows you to add the desired column as a text value/parameter?

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


costic
Frequent Visitor

I'm trying that, but for the moment, it does not work.

v-kelly-msft
Community Support
Community Support

Hi  @costic ,

 

Check the similar thread below:

https://stackoverflow.com/questions/44298772/power-query-column-name-as-parameter

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

Helpful resources

Announcements
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.