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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
laciodrom_80
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
Zubair_Muhammad
Community Champion
Community Champion

@laciodrom_80

 

 

You can specify the item position in curleybrackets

 

MyText = "5;6;9",

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

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

@laciodrom_80

 

 

You can specify the item position in curleybrackets

 

MyText = "5;6;9",

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

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.

LivioLanzo
Solution Sage
Solution Sage

@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!  

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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