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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Amardeep100115
Post Prodigy
Post Prodigy

How to remove unwanted columns dynamically

Hi 

 

I wish to remove unwanted columns from data by using "M-Code", not option "remove other colums in query editor.

 

Ref Link below

Link 

 

Thanks

AB
1 ACCEPTED SOLUTION

Hi @Amardeep100115 ,

 

Yes,for my .pbix file,pls click here.

 

Go to "edit queries">"Table">"steps",you will find my M-code there.

 

Best Regards,

Kelly

View solution in original post

8 REPLIES 8
v-kelly-msft
Community Support
Community Support

Hi @Amardeep100115

 

You can use M-code such as below:

 

= Table.RemoveColumns(Source,{"test"}&{"test 2"})

 

{"test"}{"test 2"} are the tables I removed,and you will see that in my previous table there are 3 columns:Date ,test, test 2,and with the M-code,there are only 1 column left.

 

51.png52.png

 

 
Best Regards,
Kelly

Thank you!

 

I tried the way you suggested, but not success got. could you please share your BI file to understand the same? if possible

 

Thanks occe again.

AB

Hi @Amardeep100115 ,

 

Yes,for my .pbix file,pls click here.

 

Go to "edit queries">"Table">"steps",you will find my M-code there.

 

Best Regards,

Kelly

not able to download 

Capture.PNG

AB

Hi @Amardeep100115

 

Try here.

 

Best Regards,
Kelly

JarroVGIT
Resident Rockstar
Resident Rockstar

You gave the video that answers your question?

 

Anyway, "Remove other columns" in Power query generates "M-code" for you (that is the whole point of the Query Editor, it generates the M code for you rather then having to create it yourself). You can also type in the M code yourself, I believe it is Table.SelectColumns() that returns a table with only the desired columns. 

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





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

Proud to be a Super User!




I am not much aware about M-code 

Please guide me on this more with any example

Please

AB

This question is too broad to answer. Why can't you use the "remove columns" option in power query editor? What have you tried already? Where exactly are you getting stuck?




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

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.