REGEXP_REPLACE in Google Looker Studio - aggregate

I'm trying to aggregate multiple URLs with the same path using regexp_replace
I have it set up sight now so its working with the aggregation of 1 URL, but I don't know how to change the formula to include others as well
Currently the formula I'm using is
REGEXP_REPLACE(REGEXP_REPLACE(Full page URL, '^www\\.', ' '), '^.*/test.*', 'domainname.com/test')
But, let's say I also want to aggregate domainname.com/test2 and anything with /test2 - how do I format it so that I can have multiple pathways rather than just the one?

Related

Deleting substrings throughout a column

I am trying to clean up throughout columns within a table to create a clear attribution/reference for reporting on my digital marketing campaigns. The goal is to keep one part of a string while deleting all others. All strings within my marketing campaigns have symbols separating each substring.
Attached are pictures of my current table and of the desired table.
I am essentially trying to only keep on part of the structure of a string and delete all other sub strings. I have already managed to do this successfully by applying the following formula given to be from a separate thread.
update adwords
set campaign = substring(campaign from '%-%-#"%#"' for '#')
where campaign like '%-%-%';
This worked perfectly, however, I do not fully understand why and have not found a clear answer thus far on this forum.
How would I apply this to future rows? Ad group and match type can be used for this purpose.
Many Thanks.
First thing: You do not modify source data. Do ETL instead, and transform it to a final stage. Do that periodically and thus taking care of new data.
You could just create a trigger which should work for all new data, but there are 2 caveats with that:
Failure will lead to missing data and you not being able to QA it.
If you modify the source data in an incorrect way by mistake, you cannot undo it unless you have a backup, and even then it's just too hard.
So instead look at ETL tools like Talend or Pentaho Kettle; create your own ETL scripts, or whatever. Use Jenkins to schedule all of this periodically and you're set.
Now, about the transformation itself.
for '#'
indicates that # will be an escape symbol, which means that #" will be treated as a regular quote in this case.
substring(campaign from '%-%-#"%#"' for '#')
thus, selects everything between the quotes in the pattern. % is a wildcard, same as used in LIKE comparisons. So everything in the last group will be returned. This can better be done with regular expressions
substring(campaign from '.*?-.*?-(.*)')
For the second column the regex would be ^(.*?)\s*\{
And for the third one - similar: ^(.*?)\s*\}
I would create the new table like this:
CREATE TABLE aw_final AS
SELECT
substring(campaign FROM '^\w{2}-\w+-(.*)$') AS campaign,
substring(ad_group FROM '^(\w+)\s*\{\w+\}$') AS ad_group,
substring(match_type FROM '^(\w+)\s*\}$') AS match_type
FROM adwords
WHERE campaign ~ '^\w{2}-\w+-(.*)$'
But if you must do an update, this would be how:
UPDATE adwords SET
campaign = substring(campaign FROM '^\w{2}-\w+-(.*)$'),
ad_group = substring(ad_group FROM '^(\w+)\s*\{\w+\}$'),
match_type = substring(match_type FROM '^(\w+)\s*\}$')
WHERE campaign ~ '^\w{2}-\w+-(.*)$'

VSO Sort query results using tags

Has anyone found a workaround to allow them to Sort query results using tags in VSO?
The support page clearly states that Excel (as an export should be used).
FYI: https://www.visualstudio.com/en-us/docs/work/track/add-tags-to-work-items
I was hoping someone found a way to sort based on tags where the result is:
- Tag #1
- Feature
- Feature
- Feature
- Tag #2
- Feature
- Feature
- Feature
You can define the query with the clause Tags Contains tagname. If you want to query more than one tag, you can continue add the same clauses with OR operation. Such as query tags t1 and t3 in the query, you can define as:
But the result can’t be ordered by Tags, Which I post an user voice order query result by Tags , you can vote and follow up.
Besides, you can also filter the WIT in Kanban board.

Is there any way to make markdown tables sortable?

I'd like to write my table in markdown text, but allow it to be sortable on github after its been rendered(simple asc/desc sorting by clicking on the column header.
Any way to do this?
Table sort is not supported in Github flavored markdown but one alternative is to use user script such as Github Sort Content
It's very easy to install, for instance from Chrome :
install Tampermonkey
install Github Sort Content from Greasyfork
Then tables from github.com markdown pages can be sorted like :
A possible alternative is offered with GitLab 15.4 (September 2022):
Sortable, filterable data-driven tables in Markdown
Working with tables in Markdown can be a bit cumbersome. Not only is it difficult to figure out the correct number of pipes and empty cells, but the table output is static when you save your document. If you have to sort the table by the third column in an ascending order, you end up rewriting the whole thing.
Now you can insert data-driven tables using JSON syntax as follows:
In the rendered table, you can also enable:
Sorting for specific fields using "sortable": true
Dynamic filtering of data using "filter" : true
Now it’s as simple as a click when you have to re-sort that 100-row table and as easy as a web search when you have to find that one issue reference lost in a sea of nearly identical URLs.
See Documentation and Merge Request.
There are some Chrome plugins that do this, including HTML Table Auto Sort that I've used that toggles ascending/descending sort when clicking on a column header.

Is it possible to perform a Sphinx search on one string attribute?

sql_query=SELECT id,headline,summary,body,tags,issues,published_at
FROM sphinx_search
I am working on the search feature of my Web site and I am using Sphinx, Perl and Sphinx::Search. As long as I want to search in all the attributes and I don't restrict it to just one, everything goes well. However when the user searches for a specific tag, I can't just give the result of a fuzzy search, I want to use the power of Sphinx to search only on tags or issues, maybe sometimes the user wants to search on headline and issues.
How can I perform such a task?
You need to put it in Extended Match Mode
https://metacpan.org/module/JJSCHUTZ/Sphinx-Search-0.27.2/lib/Sphinx/Search.pm#SetMatchMode
Then you can use Extended Query syntax
http://sphinxsearch.com/docs/current.html#extended-syntax
Which includes the field search operator
#tags keyword1
(Be careful with sphinx, the word "attribute" has a specific meaning - values attached to the document, useful for sorting/grouping/filtering and returning with the resultset. Whereas I think you are talking about fields. All the columns from the sql_query you dont mark as an attribute, are a field - and full text searchable)

PostgreSQL full-text search headlines do not contain enough context

I'm using PostgreSQL's full-text search capability to implement a search feature on a client's site. I'm using the ts_headline function to get the context that the search terms appear in, but the client is not happy with the selection of words displayed. In particular, the headline seems to consistently begin with the search term, whereas the client would like it to start a few words earlier.
Is there any way to either configure PostgreSQL to have this behavior, or modify the ts_headline call to get the desired results?
Edit: Apologies for not including some sample SQL in the first place.
SELECT
ts_headline('english', "text", plainto_tsquery('"endpoints"'))
FROM "Page"
WHERE to_tsvector("text") ## plainto_tsquery('"endpoints"')
ORDER BY ts_rank(to_tsvector("text"), plainto_tsquery('"endpoints"'))
Using the MaxFragments option, you might get better results. Similarly you can play with MinWords and MaxWords, e.g.
SELECT
ts_headline('english', "text", plainto_tsquery('"endpoints"'), 'MaxFragments=0, MinWords=5, MaxWords=9')
FROM "Page"
WHERE
to_tsvector("text") ## plainto_tsquery('"endpoints"')
ORDER BY
ts_rank(to_tsvector("text"), plainto_tsquery('"endpoints"'))
You will probably need to experiment.
See MinWords, MaxWords and MaxFragments in http://www.postgresql.org/docs/current/interactive/textsearch-controls.html