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
Anonymous
Not applicable

How to reference column value within M function?

Hello everybody,

 

I am trying to extract the respective Type and Category value based on the Attribute number ("|" being the delimiter). To accomplish this, I am using the Text.BetweenDelimiters function. If the attribute is 1, for example, I want to extract the value between the first and the second delimiter. If the attribute is 2, I want to extract the value between the second and the third delimiter.

 

However, I am unable to reference the attribute column. The code below returns an error. How do we reference columns within M functions?

 

Text.BetweenDelimiters(_, "|", "|", each [Attribute]-1, 0)

 

01.png

2 ACCEPTED SOLUTIONS
v-chuncz-msft
Community Support
Community Support

@Anonymous 

 

You may change it as follows.

Text.BetweenDelimiters([Category], "|", "|",  [Attribute]-1, 0)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Thanks for your reply!

 

I managed to figure it out myself after I started this thread:

 

Text.BetweenDelimiters([Category],"|","|",(Int64.From([Attribute]))-1,0)

I needed the Int64 data type to have the function accept the value from the Attribute column.

 

Thanks again!

View solution in original post

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@Anonymous 

 

You may change it as follows.

Text.BetweenDelimiters([Category], "|", "|",  [Attribute]-1, 0)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks for your reply!

 

I managed to figure it out myself after I started this thread:

 

Text.BetweenDelimiters([Category],"|","|",(Int64.From([Attribute]))-1,0)

I needed the Int64 data type to have the function accept the value from the Attribute column.

 

Thanks again!

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.