Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I'm fairly new with M and am trying to pass a list of column names as a variable to eventually allow query authors to specify columns to select for other queries. In my table "Projects," I have 9 columns. In my list "TestList," I specify four column names. One of those names (Peach) doesn't exist in "Projects." I then get the intersection of the Project column names list and TestList to give me the list of columns I actually want.
What I'd like to do next is retrieve Projects table data from the resulting list of columns. I've done some searching, but haven't found anything to answer my question--or anything I can understand anyway. I don't know if it's just a syntax thing or fundamental conceptual ignorance, so I'd appreciate any help. Here's the simple query:
let
TestList = {"ProjectId", "ProjectName", "RelativeURL","Peach"},
TabCols = Table.ColumnNames(Projects),
IntersectCols = List.Intersect({TestList, TabCols}),
RetrieveCols = Projects[IntersectCols]
in
RetrieveCols
Solved! Go to Solution.
RetrieveCols = Table.SelectColumns(Projects,IntersectCols)
RetrieveCols = Table.SelectColumns(Projects,IntersectCols)
Perfect. Thank you so much!