Referencing a date from a cell in google sheets - google-sheets-formula

I am trying to track stock prices with Googlefinance function in Sheets. I can pull the price for a date with =INDEX(GOOGLEFINANCE((B2),"price",date(2019,12,13)),2,2) which is fine but I want to input the date with Column A which has date data. So, (A1) instead of (2019,12,13)but for some reason I get errors.
This seems simple but I cannot get it to pull the date from my column. Ive tried removing DATE and just using the cell but this also doesnt work.

the formula that worked for me is
=index(GOOGLEFINANCE("YOUR_STOCK", "price",A1),2,2)
If, like you said, you already tried that and it did not work, you should link us a test sheet with your formula.

make sure A1 is really a date. you can check this with
=ISDATE(A1)
the output should be TRUE. your formula is correct:
=INDEX(GOOGLEFINANCE(B2; "price"; A1); 2; 2)

Related

Multiple Search Key in a Matrix

I'm trying to solve this problem since some days now but it seems I have reached a dead end. Maybe someone would be able to help me.
I have two sheets. The first one contains the list of my clients and their delivery number depending of the weekday.
In my second sheet I would like to get the delivery number of the client (red cells) depending of the weekday I select (yellow cells).
I tried VLOOKUP formula, INDEX/MATCH, QUERY but I wasn't able to find a way to get the delivery number depending of the client's name and the weekday. I think the main issue is that in the first sheet the weekday is a column title.
Maybe the solution is simply to build my tables differently...
Thank you for your help
You can try something like this, assuming A2 and B2 the cells of first name and first day to look:
=INDEX(Sheet1!$1:$1000,MATCH(A2,Sheet1!$A:$A,0),MATCH(B2,Sheet1!$1:$1,0))
Or, if you want this same formula for the full column:
=byrow(A2:A,lambda(each,if(each="","",INDEX(Sheet1!$1:$1000,MATCH(each,Sheet1!$A:$A,0),MATCH(offset(each,0,1),Sheet1!$1:$1,0)))))
Also doable (are perhaps more simply) using a MAP/FILTER; with your 'Caption 1' table in Sheet1!A1:D4 and your 'Caption 2' table at the top-left of Sheet2, the following in Sheet2!C2 gives you the delivery number for a many names/days as you enter in the columns alongside:
=map(A2:A,B2:B,lambda(name,day,ifna(filter(filter(Sheet1!B2:D4,Sheet1!A2:A4=name),Sheet1!B1:D1=day))))
N.B. The IFNA blanks out errors for those rows where a Name/Day pair hasn't been entered yet. Extend the ranges in the filter to suit your real data.
all you need is simple vlookup:
=INDEX(IFNA(VLOOKUP(A9:A11&B9:B11,
SPLIT(FLATTEN(A2:A4&B1:D1&"​​"&B2:D4), "​​"), 2, )))

Sorting date as 2nd criteria gives wrong order

The date is in the correct format ie YYYY-MM-DD. If I sort just on date it sorts to correct order however if i sort on another field first with date the second criteria it is sorted correctly on first criteria but the date is sorted by DD first MM second and YYYY last. Out of curiosity I tried the same file in Excel which sorted correctly. Can anyone explain the difference and how to get a correct sort in Calc? Using 2 criteria in Calc does not work. I tried sorting on date first and species second. Date order was correct but species were jumbled.
The data is a spreadsheet download of an online data base where we record squirrel and other species sightings in the forest. The entries are not in date or species order. There are many fields for each entry but I am trying to sort first to species and then each species to be in date order. It is for an animation using Time Manager.
I have re-asked the question with edit because the question was closed, for what reason I don't know.
The sort does work correctly, tried again and all sorted as it should. Tried to reproduce strange date order but can't. Have no idea what went wrong originally.

Sort Google Sheets spreadsheet by date, not by string

I use Google Sheets to keep a list of applications I am doing. In each row there is a date field. I want to sort by date now. The first row is frozen using View - Freeze - 1 row. When I select the whole table, press Data - Sort range... and then check Data has header row the sheet is sorted. But not by date but by string. The format of the cells is date. Is only string sorting possible? If yes, I would have to reformat the whole document to dates like 2017-01-11, correct?
The solution was to replace the . by /. Seems as if the common german format using . is not yet supported. Make sure the date is recognized as date. If the cell is right-aligned it worked, if not it did not work.
I learned that you can create a custom date format using the ..
Now the date is entered 10/01/2017 but displayed 10.01.2017. Just the way I wanted.

How can I get a Telerik Reporting graph to sort the x-axis by a date and format that date?

I have a Telerik report with a graph. The graph's x-axis is a series of dates. Our client would like those dates in order from oldest to most recent. They also want the dates formatted to not include the time portion of the date. I've tried for the past day to get this to work and can't figure it out. Can someone explain how to do this?
I started out with a graph based on this query:
SELECT AnalysisNumber
, convert(varchar, DateSampled, 01) as DateSampled
, ViscosityAt100C
FROM tblSample
ORDER BY a.DateSampled ASC
The results look correct with the dates in order from oldest to most recent:
but a graph is produced where the dates were not in order:
I can't begin to include all the setting for the graph, but here is what I think is the relevant part. Let me know if there's something else I can show you.
Notice the sorting is by DateSampled which is now, of course, text not a date.
If I remove that sorting (to try to preserve the original sorting from the SQL query), the graph no longer works:
So I tried to use a date instead of text. The query is now this:
SELECT AnalysisNumber
, DateSampled
, ViscosityAt100C
FROM tblSample
ORDER BY a.DateSampled ASC
...the output looks the same:
and the graph looks like this:
The dates are sorted the way I want, but all the dates have a time element that I don't want because it's irrelevant and it takes up too much space.
I tried changing the type in SQL:
Cast(DateSampled as Date) as DateSampled
but it still showed the time in the graph.
I tried formatting it using the properties for the x-axis:
but it did not change the formats of the date. In fact, changing to any of the formats in that property did not change anything.
Lastly I tried to include both a string and date in my query:
SELECT AnalysisNumber
, convert(date, DateSampled) as DateSampledText
, DateSampled
, ViscosityAt100C
FROM tblSample
ORDER BY a.DateSampled ASC
and using the DateSampledText to group by and the DateSampled to sort by:
it just ruins my graph again:
I tried adding the text version to sorting and other variations, but never got the graph back to where it was showing data.
Sorting and formatting a graph doesn't sounds like it should be difficult. This was supposed to be one of the final changes before going into production and I've already spent so much time on this. Can someone tell me how to make this work? Thank you!
I believe you need to change the scale of your graph. I think by default it is Category Scale, but when using dates, you would need to change it to DateTime scale.
In your graph properties, where you set the Format of the X-Axis, there should be a property called Scale. Try setting it to DateTime.
Keith
The reason you can't format the dates is because the graph is treating them as strings.
You need to change the x axis to be of type DateTime Scale instead of Category Scale. Category scale is the default and is more appropriate for when you are graphing the number of Apples, Oranges, and Pears, for example.
In the standalone report designer the setting is under Presentation Category > Coordinate Systems > cartesiancoordinatesystem1 > X Axis > Scale
..
In addition to changing the scale type, because the scale expression is now not just a string, you also need to set the X value on your line series.
This setting is under Presentation Category > Series > lineseries1 > X
For some unknown reason the setting should not be "=Fields.DateSampledText", but "DateSampledText". The documentation is irritating bare of details like this.

Xpages sorting date

I'm stuck with sorting and showing the correct date in Xpages.
It is saved in format "dd.MM.yyyy" and it's a string.
Now why it's a string and formated that way, is because my boss has special wishes. And when I want to sort it from the newest date to older it does something like this:
26.05.2015
24.06.2014
22.04.2015
21.04.2015
20.03.2014
It starts sorting by day.
Is there a way to make it sort it like it should?
I see that i can write a Computed value to Sort column in view column header for date. But i don't know how to even start.
Change the underlying Notes view to get your date column into right order.
Convert the date strings to real date values in views column formula. Assuming your field is called DateText then your formula would be
#Date(#ToNumber(#Right(DateText; 4));
#ToNumber(#Middle(DateText; 3; 2));
#ToNumber(#Left(DateText; 2)))
It would be easier to use just #ToTime(DateText) but this can fail depending on server's local settings. Your date string format would work for a server with German locale settings but not for US. That's why is my suggested solution "safer".
If the date time value doesn't solve your problem and you do not transform your date via #Text (as mentioned in the comments) then create another (hidden) column BEFORE your column that should be displayed. Make this a true date (from your item), sort it and unsort the column to display.
Otherwise use this formula in the newly created sorted column:
#Text(#Year(yourDate))+"-"+#Right("00"+#Text(#Month(yourDate));2)+"-"+#Right("00"+#Text(#Day(yourDate));2)

Resources