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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Power Query M- How to select all items in a list after a certain column name (not based on position)

Hi all,

 

At the moment I have a table for which I calculate values based on the columns starting with column 42. 

So I used List.Skip(Table.ColumnNames(Source),42) 

to get the columns on which I want make calculations. This all works fine as can be seen in the picture below. I had to do it this way because on random occasions new months can pop up after the last column. 

commodity_check_0-1616675930246.png

However, now someone asked me to aggregate all data after "Dec 2021". Like I mentioned the amount of columns after Dec 2021 changes all the time.

 

The difficult part is that when March ends, the first item in the list becomes "Apr 2021". So I can't select all data after "Dec 2021" using the index, like I did in the example above. I need to select the index of all data after Dec 2021 using the name "Dec 2021" in the list. However, as far as I know, I only can select an item in the list based using the index number, not the other way around.

 

How can I tackle this?

 

I want to keep it flexible so I can easily change the data to aggregate in the advanced editor. So in a few months I'd like to aggregate all data from Mar 2022 for instance. It would be great of I would have to simply change "Dec 2021" , to "Mar 2022" somewhere in the query editor.

 

Kind regards,

commodity_check

 

 

 

 

1 REPLY 1
PhilipTreacy
Super User
Super User

Hi @Anonymous 

I can't see youur data but my gut tells me your data is in the wrong format.  You should have a single column for date, not multiple columns for every month/year - as you already see, this cuases the number of columns to change.

If youu can show what your data looks like, and provide some sample data, perhaps there's a more efficient approach to this problem.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors