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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Text.PositionOfAny

I'm using the text function "Text.PositionOfAny([Assistência], {"S"}, Occurrence.All)" to get the sequence of S from a string field.

 

This is the string field

"NNNNNNNNNSNNSNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"

 

This is the return of the function

List

 

Extract values ​​and then add dash separator

9-12

 

How do I make this function start from 1, today it starts from 0, so my answer would be 10-13?

 

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Added Custom" = Table.AddColumn(Source, "Custom", each List.Transform(Text.PositionOf([Text], "S", Occurrence.All), each Number.From(_) + 1)),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), "-"), type text})
in
    #"Extracted Values"

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ahmedx
Super User
Super User

pls try this

Text.Combine(
     List.Transform(
       Text.PositionOfAny("W"&[Assistência], {"S"},     Occurrence.All), Text.From),
       "-")

Screenshot_1.png

Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Added Custom" = Table.AddColumn(Source, "Custom", each List.Transform(Text.PositionOf([Text], "S", Occurrence.All), each Number.From(_) + 1)),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), "-"), type text})
in
    #"Extracted Values"

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

@Ashish_Mathur Thank you for your help,
The step where I do this validation I cannot call the source, in the previous step I make a line filter, as I adapted the source to start the previous step,

 

Solution

List.Transform(Text.PositionOf([Assistência], "S", Occurrence.All), each Number.From(_) + 1)

I cannot understand your message.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.