Is it possible to change a section of URL text when using IMPORTXML to a reference cell - google-sheets-formula

So I am trying to use IMPORTXML to pull data for stocks, but I want to simplify it with referencing a cell to change the stock name in the URL.
=IMPORTXML("https://www.marketwatch.com/investing/stock/aapl/financials/balance-sheet","/html/body/div[3]/div[6]/div/div[2]/div/div/table/tbody/tr[3]/td[2]/div/span")
So is there a way to make the "aapl" part of the URL reference to a cell that has a new stocks ticker to change the URL to a that new stocks balance sheet?
I am very new to this, sorry if my question doesn't make sense or is dumb. Thanks for any help provided.

Try this:
=IMPORTXML("https://www.marketwatch.com/investing/stock/"&A1&"/financials/balance-sheet","/html/body/div[3]/div[6]/div/div[2]/div/div/table/tbody/tr[3]/td[2]/div/span")
Change A1 with the cell you want

Related

Adding labels to explorations data in GA4?

Is it possible to add an arbitrary label to a GA4 exploration?
For example I am tracking outbound link clicks for phone numbers. I would like to add a short description to each number.
I was thinking something like if Link URL equals 'tel: xx xxxx xxx' a label would say 'city office'. Any ideas on this?
Well... You have GTM tag added to your question. This implies that you're ok having a GTM solution.
Well, in GTM, find the tag that fires on the phone clicks, add a custom event property to the tag that would contain the description of the numbers, make a custom JS (CJS) or a look up table (LUT) or better a regex LUT, and map your numbers to descriptions.
Then go to GA and register that event property as a custom dimension. Done.
You could also override the link url dimension in GTM with a CJS var that would generate descriptions in the same dimension, but it's not a good idea to override default dimensions unless you're confident about what you're doing.
GA4 has capabs to modify event properties, but it's extremely basic and won't be able to change properties based on their values. Also, it's a bad idea to have data modification logic in GA. It's best to contain all data modification logic in one place whenever you can help it.

Google spreadsheet formula for url with a variable

What's the formula to display an url in google sheet when part of said url is a variable from another cell?
I'll explain: in one cell I have this formula (used to scrape text with class 'description' in an html webpage, doesn't matter for the purpose of the question though)
=importXML("http://www.xxx.it/code/9788823506183/doc/book.html","//span[#class='description']")
The numerical part changes everytime based on the value in another cell, say B3.
Tried =importXML("http://www.xxx.it/code/(B3)/doc/book.html","//span[#class='description']") but of course it won't work.
Then I thought I could dinamically create the url in B2 and do like this:
=importXML("B2","//span[#class='description']")
One step closer but I'm stuck anyway, how can I generate such url in B2? I can't find a suitable function in the docs. I could only come up with:
in A1 = 9788823506183
in B2 = http://www.xxx.it/code/("A1")/doc/book.html but it's not the correct syntax. :(
In Excel, you'd do something like the following. Give it a try in a google spreadsheet.
=importXML("http://www.xxx.it/code/" & B3 & "/doc/book.html","//span[#class='description']")
Use CONCAT in Google Sheets.
=CONCAT("http://www.xxx.it/code/(", $B2,")/doc/book.html")
You may need a formula to get the exact spot in the string.
The following example starts a timer based on a cell value but could be adapted to build a URL out of any cell values. Assume that there is a number of minutes that you want to make a timer for is in $C20
1) Make a cell that builds the first part of the URL, in my case $E27:
=CONCAT("https://www.google.com/search?q=set+timer+for+", $C20)
2) Make a second cell that completes the URL, in my case $E28:
=CONCAT($E27,"+minutes")
3) Make a cell that contains a hyperlink that will call up the timer:
=HYPERLINK($E28, "Start a timer for cell value C20")
Then when you click on the cell you made in #3 a hyperlink will hover over and you can click on it.

Backend Product Info Grid Modificaiton

I want to create a new text field right under the SKU text field in the Product Information > General tab and populate it with the product's attribute set value. What I want can be seen in the picture below.
Unfortunately, for the past 4 hours I have been trying to locate the file that includes the code which produces the specific layout but so far I had no luck. I 'd be really grateful if anyone could give me a heads up.
Thank you for your time!
Enable backend path hints to find out which file it is. You can do it this way.
http://www.classyllama.com/development/magento-development/enable-templateblock-hints-in-admin-panel
Please note this is basically hacking. A better way to do it would be to follow something like this
http://www.marketingadept.com/blog/2014/01/magento-developers-add-a-custom-field-to-the-category-admin-page/
It's up to you, speed or do it the right way. Goodluck

Force a Content to in new page when generating a PDF

Im using play framework and rendering PDF usin rednerPDF() method.
I would like to display some part of content always be in new page.
For Example I have two tables, One table should be in first page and another table should in next page instead of continue from first page. The first table contents are dynamic and we can't sure the height of the table.
Is it possible?
Is it possible?Yes.
You said one table(first one) should be in first page,and again you said its content is dynamic.Now my question is it span over pages and in the next page you want to write second table?This is a generic scenario and what you mentioned is specific one.
You can start trying using two properties of PdfPTable setSplitLate() and setSplitRows()(just google it out for details read Itext In Action).Just keep Two table as two Rows of outer table.set those two property for inner as well as outer in some way as you want(i.e generic case/Specific case).
Another alternative way is use writeSelectedRows() method over PdfContentByte(I don't konw which Object you gonna use for manipulating pdf but you can get it from PdfWriter,*PdfStamper* by using getDirectContent/*UnderContent*/OverContent) after generating table.To use this method you have to set total width of the table so the height can be calculated by method getTotalHeight of PdfPTable.If You use this height properly you absolutely know where your table ends.But all these specific part you have to read & understand first.
With yahp you can use a special html tag to force a page break
<yahp:pb />
we can achieve this by page-break-after:always
Please refer
Alternate to PDF for dynamically generated document with page breaks

DataTables - Adding filtering function to a column

I have a table which have information which I would like to exclude from the search box. For example, in one of the columns I have some text and then links, it looks like that:
<td>
<div>John Doe</div>
<div>
View |
Edit |
Delete
</div>
</td>
Of-course in this case I would like the search box to consider only "John Doe" as a text to be searched.
I draw my table in php (I use Symfony-2) and apply the DataTable plugin using dataTable function with jQuery. I got the impression that what I want is possible, but couldn't manage to achieve it. Other discussions like http://www.datatables.net/forums/discussion/255/customising-the-way-the-filter-works/p1 neither helped me to solve this problem.
Thanks!
I'm sure there are ways to customize the actual search function (you could specify the type for the column using mDataProp and then write a custom filter for that type maybe?).
But a different way to go about it is to have your PHP script only supply the name: John Doe. This will be the original data for the cell.
Then in your column definitions, use fnRender() to format the cell using the layout you use in your question -- and have it automatically parse the name to create the links you want (assuming all names are first and last, and all links just use the combined first/last names, this should be fairly easy to implement).
Then set bUseRendered to false for that column and it will perform all of its sorting and filtering based on the original content, not the new content. See more here.

Resources