Substr - Instr Function Error in Power BI - search

I used the SEARCH function in Power BI but finds the location of the character I want to find incorrect.
The screenshot will tell you better.
Actually, I want to extract source system (android - ios etc). Essentially I can do with SQL using instr - substr but I want to use DAX Language.
Please help.

I tried to reproduce this. I had to change the semicolon to a comma to separate the arguments.
You can use MID to return substrings, which takes the start position and length as arguments.
=var str_start = search("Twitter for",[source])
var str_end = search("</a>",[source])
return mid([source],str_start, str_end-str_start)

Related

How to count occurrences of a character in a string in Presto?

I am trying to find the number of frequency of a character in a string in Presto.
like 129.11.20.0 and I wan to find number of dot . in this string.
just wondering if any function available
I was looking for the same in AWS athena, which is a managed presto service. It doesn't support regexp_count, so I used the following expression instead:
SELECT CARDINALITY(REGEXP_EXTRACT_ALL('1.1.1.1', '\.'))
You can use regexp_count function.

COBOL substring between two finite points

I understand that the string_variable(start:length) can be used to get a substring of a string given a starting point and substring length, however, I am finding that I often need to get a substring between a 'start' and 'end' point.
While I know I could always do this:
SUBTRACT start FROM end GIVING len
string(start:len)
It seems cumbersome to have to do so every time when I am writing programs that use this functionality often. Is there perhaps a quicker/built-in way of achieving this?
How about?
move str (start-pos : end-pos - start-pos + 1) to ...
You can subtract the first from the last, but you need to add 1 to get the correct length.
STRING is a statement name, as is START, and END is reserved. LENGTH is a function name. I avoid those in anything that looks like code.

Finding a character inside a string in Excel

I want to remove all the characters from a string expect whatever character is between a certain set of characters. So for example I have the input of Grade:2/2014-2015 and I want the output of just the grade, 2.
I'm thinking that I need to use the FIND function to grab whatever is between the : and the / , this also needs to work with double characters such 10 however I believe that it would work so long as the defining values with the FIND function are correct.
Unfortunately I am totally lost on this when using the FIND function however if there is another function that would work better I could probably figure it out myself if I knew what function.
It's not particularly elegant but =MID(A1,FIND(":",A1)+1,FIND("/",A1) - FIND(":",A1) - 1) would work.
MID takes start and length,FIND returns the index of a given character.
Edit:
As pointed out, "Grade:" is fixed length so the following would work just as well:
=MID(A1,7,FIND("/",A1) - 7)
You could use LEFT() to remove "Grade:"
And then use and then use LEFTB() to remove the year.
Look at this link here. This is the way I would go about it.
=SUBSTITUTE(SUBSTITUTE(C4, "Grade:", ""), "/2014-2015", "")
where C4 is the name of your cell.

String functions in Sybase ASE

I want to retrieve "name" from "My_name_is_ABC", how to do it in Sybase-ASE ?
I tried finding on internet but inbuild functions i saw are not supported in ase.
Atleast i need to know how to do find index of a string.
Sybase ASE does have inbuilt string functions as Documented Here. You can use SUBSTRING and CHARINDEX function to get your desired result like below
select substring("My_name_is_ABC",charindex("_", "My_name_is_ABC")+1,4)
Syntax for Substring function : substring(expression, start, length )
select substr('My_name_is_ABC',locate('My_name_is_ABC','name'),4) from dummy

parsing a string that ends

I have a huge string. I need to extract a substring from that that huge string. The conditions are the string starts with either "TECHNICAL" or "JUSTIFY" or "ALIGN" and ends with a number( any number from 1 to 10) followed by period and then followed by space. so for example, I have
string x = "This is a test, again I am testing TECHNICAL: I need to extract this substring starting with testing. 8. This is test again and again and again and again.";
so I need this
TECHNICAL: I need to extract this substring starting with testing.
I was wondering if someone has elegant solution for that.
I was trying to use the regular expression, but I guess I could not figure out the right expresion.
any help will be appreciated.
Thanks in advance.
Try this: #"((?:TECHNICAL|JUSTIFY|ALIGN).*?)(?:[1-9]|10)\. "

Resources