The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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!