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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

0

Text.PositionOf returns list when occurrence is used

The Power Query function Text.PositionOf returns a list when the 'occurrence' parameter is set, so that the common scenario below gives error 'We cannot apply operator + to types List and Number'

 

 

Text.PositionOf("String with multiple spaces", " ", 2) + 1

 

 

Documentation states that 'An optional parameter occurrence may be used to specify which occurrence position to return (first occurrence by default).' - and that's all it states. It appears this happens because despite declaring the type of the parameter as nullable number, it is expecting an Occurrence.Type enum, so numbers higher than 1 do not correspond to the position within the list that's expected.

 

The documentation is misleading, so either that needs to be changed, or the parameter behaviour updated to a more reasonable interpretation, or at least restricting to the enum.

 

FYI I think the best workaround to this is just use Occurrence.All and retrieve the item you want by index

Status: Delivered
Comments
Anonymous
Not applicable

Hi  @JoshT 

Thanks for your feedback and workaround .You can vote the idea and comment there to improve this feature. It is a place for customers provide feedback about Microsoft Office products . Whats more, if a feedback is high voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version in the future.

 

Best Regards,
Community Support Team _ Ailsa Tao

JoshT
Advocate III

Hi @Anonymous ,

The documentation https://learn.microsoft.com/en-us/powerquery-m/text-positionof is still incorrect/highly misleading and needs to be changed

tdalon
New Member
Absolutely agree: this is a bug in the implementation and the documentation is currently wrong. Totally misleading.