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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

If Text.Contains Help

Hi folks.

 

I'm trying to verify if a text contais "#<number>." (Hashtag, number and a dot) and this number can be anyone (from 0 to infinity)

 

Can anyone help me with powerquery formula?

 

TY!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous 

1.  Create custom function 'fnRegExpExtract':

let fx=(txt as text)=>
    Web.Page(
        "<script>
            var x = '"& txt & "';
            var delim = '-';
            var pattern= /" & "\#\d*\." & "/gi;
            var result=x.match(pattern).join(delim);
            document.write(result);
          </script>")[Data]{0}[Children]{0}[Children]{1}[Text]{0}
in
    fx

2. Add new column by 'Invoke custom function', choose function and column with data or add this code; 

Table.AddColumn(prev_step, "fnRegExpExtract", each try fnRegExpExtract([column_with_data]) otherwise null)

View solution in original post

1 REPLY 1
Anonymous
Not applicable

@Anonymous 

1.  Create custom function 'fnRegExpExtract':

let fx=(txt as text)=>
    Web.Page(
        "<script>
            var x = '"& txt & "';
            var delim = '-';
            var pattern= /" & "\#\d*\." & "/gi;
            var result=x.match(pattern).join(delim);
            document.write(result);
          </script>")[Data]{0}[Children]{0}[Children]{1}[Text]{0}
in
    fx

2. Add new column by 'Invoke custom function', choose function and column with data or add this code; 

Table.AddColumn(prev_step, "fnRegExpExtract", each try fnRegExpExtract([column_with_data]) otherwise null)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.