cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

M language help: get an element from a list by index

I'm trying to get a specific element by index from a list obtained splitting a text by delimiter, but I don't find the right function for this goal. Using List.First or List.Last I can get first and last elements, but what function should I use to get an element by index?

 

 

MyText = "5;6;9"

MyList = Text.Split(MyText, ";")

 

 

Thnaks a lot

 

Luca
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: M language help: get an element from a list by index

@laciodrom_80

 

 

You can specify the item position in curleybrackets

 

MyText = "5;6;9",

MyList = Text.Split(MyText, ";"),
Myitem=MyList{2}
Try my new Power BI game Cross the River

View solution in original post

3 REPLIES 3
Highlighted
Solution Sage
Solution Sage

Re: M language help: get an element from a list by index

@laciodrom_80

 

I guess this sis what you are after:

 

https://docs.microsoft.com/en-us/powerquery-m/list-range

 


 


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


Proud to be a Datanaut!  

Highlighted
Super User III
Super User III

Re: M language help: get an element from a list by index

@laciodrom_80

 

 

You can specify the item position in curleybrackets

 

MyText = "5;6;9",

MyList = Text.Split(MyText, ";"),
Myitem=MyList{2}
Try my new Power BI game Cross the River

View solution in original post

Highlighted
Impactful Individual
Impactful Individual

Re: M language help: get an element from a list by index

I found I would have to use ;

 

MyText = "5;6;9",

MyList = Text.Split(MyText, ";"),
Myitem=MyList{1}

as the indexing seems to start at 0 for me not 1.

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Top Solution Authors
Top Kudoed Authors