I have a table of events from google sheets that I want users to be able to filter by date in Google Looker Studio. The events have various lengths, so each has a start and an end date in the table (as well as a bunch of other columns). For example:
Event
Start Date
End Date
A
02/15/2023
02/20/2023
B
03/01/2023
04/30/2023
C
02/23/2023
03/01/2023
I want users to be able to filter for anything that is happening in the event range they select. For example, if they input the date range 02/26/2023 - 03/15/2023, the table should filter down to show events B and C, since those have ranges overlapping their input data range.
I've tried a few different approaches that all have drawbacks:
Using the Looker Studio date range control. This seems to only filter based on the Start Date OR the End Date, and not have the ability to look at both.
Applying a Date Filter in the chart. If I apply the following filter (under Chart - Filter - Table Filter), it works great to show anything overlapping the desired date range:
Include - Start Date - Less than or equal to - 03/15/2023
AND
Include - End Date - Greater than or equal to - 02/26/2023
However, I had to put these dates directly into the filter, which is not what the user should have to do. Is there a way I can have them input the date range they are interested as a control, and I can feed that information into the Date Filter above? (So they would put in a start date and end date that would replace where I have hard coded 02/26/2023 and 03/15/2023 above).
I have also set up this filter in Google Sheets to work exactly as I want it. Anyone can enter a start date and end date in a couple cells, and I use the filter() function with the same logic as in #2 above to filter the table down to what I want. The disadvantage of google sheets though, is if multiple people are there at the same time, they do not have their own view of the report. I switched to Looker Studio because it allows view-only users to filter their report independently.
Edited to add: This report is intended to be used by viewers with limited experience using google sheets or looker studio, and possibly on phone or browser, so I'm trying to make the filtering as easy as possible.
the ability to filter data independently & at the same time for multiple users is natively possible in google sheets with Filter Views:
My original data looks like this:
Original Data
I'm looking for a way for my query to return information ONLY for the latest date associated with each Test. For that date, I am looking to get the count number of customers and the $ Paid total. What's complicating my effort is the fact that multiple people could take the Test at a given date and across dates.
The ideal results should look like something like this:
Ideal Results
I am getting information submitted into this table via Google Forms in real-time hence row range will be dynamic & need a solution that can give me the info I am looking for at any given time.
Here is the one that came the closest for me (although still far off as it does not show the Count or the Total $):
=ARRAYFORMULA(VLOOKUP(QUERY({ROW(A2:A),SORT(A2:D)}, "SELECT MAX(Col1) WHERE Col3 IS NOT NULL GROUP BY Col3 LABEL MAX(Col1)''",0),{ROW(A2:A), SORT(A2:D)},{2,3,4,5},0))
Spreadsheet link for Original data and the results of the above query:
Google Spreadsheet with Original Data
I would really appreciate any insights or help from anybody.
Possible solution (based on your document)
https://docs.google.com/spreadsheets/d/1tADqNS4YtdDrMjToCNy2auKB_eNuMdMEA4ahmYJi_3M/edit?usp=sharing
Details:
Lastest date for a test could be found using FILTER MAX functions
Count for a test (at lastest date) could be found using COUNTIFS
Sum for a test (at lastest date) could be found using SUMIFS
I'd like to know if it is possible to query a past exchange rate on Google Spreadsheet.
For example; using formula =GoogleFinance("CURRENCY:USDEUR") will return the USD/EUR rate at this present moment. How can you retrieve a historic rate?
In order to retrieve the historical rate, you have to use the following formula:
=GoogleFinance("eurusd","price",today()-1,today())
where today()-1, today() is the desired time interval, which can be explicitly defined as the static pair of dates, or implicitly, as the dynamically calculated values, like in the example above. This expression returns a two-column array of the dates and close values. It is important to care about the suitable cell format (date/number), otherwise your data will be broken.
If you want to get the pure row with the date and currency exchange rate without column headers, wrap your formula with the INDEX() function:
=INDEX(GoogleFinance("eurusd","price",today()-1,today()),2,)
To retrieve the exchange rate value only, define the column number parameter:
=INDEX(GoogleFinance("eurusd","price",today()-1,today()),2,2)
To get today's currency exchange rates in Google Docs/Spreadsheet from Google Finance:
=GoogleFinance("eurusd","price",today())
A shorter way to get today's rates:
=GoogleFinance("currency:usdeur")
P.S. There is also the way to get live currency exchange rate in Microsoft Excel.
Try,
=GoogleFinance("usdeur","price",date(2013,12,1),date(2013,12,16))
Make sure that the dates are as per your spreadsheet settings.
Edit as comment, changed date for capturing single day data:-
Only with headers:
=INDEX(GoogleFinance("usdeur","price",date(2013,12,3),date(2013,12,4)),,2)
without headers:
=FILTER(INDEX(GoogleFinance("usdeur","price",date(2013,12,3),date(2013,12,4)),,2),INDEX(GoogleFinance("usdeur","price",date(2013,12,3),date(2013,12,4)),,2)<>"Close")
The instructions for all related to googlefinance are in here: https://support.google.com/docs/answer/3093281
Remember the actual Google Spreadsheets Formulas use semicolon (;) instead of comma (,).
Once made the replacement on some examples would look like this:
For a 30 day INDEX of USD vs EUR you should use (note that in the case of currencies they go together in the same first variable):
=INDEX(GoogleFinance(USDEUR;"price";today()-30;today());2;2)
TIP: You can get the graph over the entire size of the cell by simply changing INDEX for SPARKLINE, like this:
=SPARKLINE(GoogleFinance(USDEUR;"price";today()-30;today());2;2)
Vasim's answer is excellent, however notice if you want the exchange date on that day only, you can omit the range and just specify the day such as the following
=FILTER(INDEX(GoogleFinance("usdeur","price",today()),,2),INDEX(GoogleFinance("usdeur","price",today()),,2)<>"Close")
You may notice that GOOGLEFINANCE will return N/A for some dates, this is because the date is a day off (usually a weekend), what you can do is to get the last working from the specified date, e.g. Jun 21st 2015 is Sunday, so you should request the rate for Jun 19th (Friday), you can do this via WORKDAY function as was suggested here:
WORKDAY("6/21/2015"+1,-1)
So, the resulting formula will look something like that:
INDEX(GoogleFinance("CURRENCY:USDRUB", "price", WORKDAY("6/21/2015"+1,-1),1),2,2)
Additionally, you want to get the exchange rates for future dates you can additionally check if the date is in the future and if so, just use the today date:
WORKDAY(IF("6/21/2099">TODAY(),TODAY(),"6/21/2099")+1,-1)
For bigger spreadsheets, Google Sheets limitations usually will show randomly the following error:
Error Function INDEX parameter 2 value is 2. Valid values are between
0 and 1 inclusive.
Even modifying Index() and GoogleFinance() following the expected parameters GOOGLEFINANCE(ticker, [attribute], [start_date], [end_date|num_days], [interval]) the error will continue.
A workaround is to copy smaller parts into new spreadsheets but often it will fail.
As an alternative, I used ImportXML as web scraper for x-rates historical currency exchange data.
=index(IMPORTXML("https://www.x-rates.com/historical/?from="&N2&"&amount="&K2&"&date="&YEAR(B2)&"-"&TEXT(B2,"mm")&"-"&TEXT(B2,"dd")&"","//td[#class='rtRates']"),1)
I'm assuming column B are dates, K is for amounts and N for currencies.
Randomly it also will fail for a 2000+ rows spreadsheet but overall for my requirement, it worked too much better than GoogleFinance()
ImportXML examples
The ImportXML Guide for Google Docs from beginner to advanced
Other option is using the CurrencyConverter function from this Google Sheets add-on.
It is fast and and has simple syntax. For example,
=CurrencyConverter(100, "USD", "EUR", "2/28/2020")
returns 91.09957183
I'm looking to build an analytics dashboard for my data in a rails application.
Let's say I have a list of request types "Fizz", "Buzz", "Bang", "Bar".
I want to display a count for each day based on type.
How should I do this?
Here is what I plan on doing:
Add get_bazz_by_day, get_fizz_by_day, etc to the appropriate models.
In each model get all records of type Fizz, then create an array that stores date and count.
format in view so a JS library can format it into a pretty graph.
Does this sound reasonable?
Depending on number of records, your dashboard can soon get performance problems.
Step 1 is misleading. Don't get the data for each day individually, try to get them all at once.
In Step 2 you can have the database do the the aggregation over days, with the group method.
See http://guides.rubyonrails.org/active_record_querying.html#group
Fizz.select("date(created_at) as fizzed_day, count(*) as day_count").
group("date(created_at)")
In Step 3 you need to take care that days without any fizzbuzz are still displayed, as they are not returned in the query.
I have essentially a log file in a Google Sheets. Columns are "Date/time", "user", "asset accessed", and there will be multiple entries for the same date, though usually not time.
I'd like to use the timeline graph to show user activity, but the graph requires an aggregate view with one date (no time) per row, with a numeric count in second col. Is there a way using functions within Google Sheets to generate an aggregate "view" of this data and pass this to the timeline graph?
Well, I guess you'll have to create an auxiliary sheet, or just some columns with the summarized values for you chart.
From your description, I'll assume you're using 3 columns (ABC). Let's use columns D, E and F with the following formulas:
=ArrayFormula(Trunc(A:A))
=Unique(D:D)
=ArrayFormula(CountIf(D:D;E:E))
Since date values are actually a number (qtt of days since the epoch), and hours are decimals, the Trunc formula gets rid of the "time" part and leaves only the date. Just format the cells (apparently numbers) as dates and you'll see. Then Unique and CountIf do the summarizing.
There's surely different ways of doing this, perhaps more "elegantly", in a single formula. But I think that in this way it's more easy to understand and learn from. Also, you'll probably need to adapt the ranges to your actual columns positions (I hope that's not a problem).