Forum Discussion
L25
1 year agoRegular Visitor
Stripping out the query string in a URL returning blank
Hello, I am trying to strip out everything including and after the ? from my url [page_location] to report on page usage, I am also stripping out my own website address to shorten the result. eg ...
- 1 year ago
Try this revised DAX.
Extract Before Question = VAR _search = "?" // Define the character to search for in the URL VAR _replace = "|" // Define a replacement character for the question mark VAR _url_replace = SUBSTITUTE(MAX(Query1[page_location]), _search, _replace) // Replace the "?" with "|" in the page location (URL) VAR _url = _url_replace // Assign the modified URL to a new variable VAR _position = SEARCH(_replace, _url, 1, LEN(_url)) // Find the position of the replaced character in the URL VAR _result = LEFT(_url, _position - 1) // Extract the portion of the URL before the "|" character (excluding it) VAR _debug = "URL: " & _url & " | Search Pos: " & _position // Debugging output to see the URL and position of the replacement character RETURN _result
aduguid
Memorable Member
1 year agoTry this revised DAX.
Extract Before Question =
VAR _search = "?" // Define the character to search for in the URL
VAR _replace = "|" // Define a replacement character for the question mark
VAR _url_replace = SUBSTITUTE(MAX(Query1[page_location]), _search, _replace) // Replace the "?" with "|" in the page location (URL)
VAR _url = _url_replace // Assign the modified URL to a new variable
VAR _position = SEARCH(_replace, _url, 1, LEN(_url)) // Find the position of the replaced character in the URL
VAR _result = LEFT(_url, _position - 1) // Extract the portion of the URL before the "|" character (excluding it)
VAR _debug = "URL: " & _url & " | Search Pos: " & _position // Debugging output to see the URL and position of the replacement character
RETURN
_result