latest timestamp with not null values using multiple conditions - excel-formula

I have been using Google Forms to get some data from users. This is the output.
data table 1
I used a a combination of index match and Max ifs functions, but was unable to get the cost value of 4 and the comment "waste" for Berlin city and week W02. Furthermore, I wanted to have the latest non-null value of cost using the conditions "city," "week," and "cost," and the same for the comment.
https://docs.google.com/spreadsheets/d/1GJpSUo0vxiHhkP_CvH7AEnXqHX9UCmoZKeH4M6fz5YI/edit#gid=1377058657
Please guide me how to resolve this.
I want to take this response to another sheet where I can export the latest timestamp value of the cost and comments for city and week like this
output required

Related

Please can I get some guidance on techniques using the Unique Function

To clarify, I will attack the code myself, however, it's the order and techniques to do this I need some guidance with.
I have a table with 4 columns. The table has 40000 rows. The columns are Date, Name, location, company.
I want to see how many times someone in the name column, appears in the database. I then want to apply a date filter to that. This I have managed to do if somewhat clunky.
My problem is that the unique function only returns the name, when i apply it to that column. and i need it to return the location and company so that i can sort on that too. How would you go about doing that?
I have used unique on the name column. It returns a spilled over list of about 4000 names. I then
use this code =COUNTIFS(MyName,$A2,MyDate,">="&DATE(List!$D$2,List!M$4,List!M$5),MyDate,"<="&DATE(List!$D$2,List!M$4,List!M$3)) to return the number of entries per month. A2 is the unique return column.
Any guidance would be appreciated.
Allan

Excel - Index-Match with duplicate ids, need row with min date greater than date

I am trying to get the ID associated with a user ID, but the reference table I am pulling from is historical and effective dated. However, I need to pull the MINIMUM End Eff. Date that is GREATER THAN my row's source date, and instead of grabbing the date, I need to get the ID that is associated with that date's row.
For example:
Ideal ID Value for the top row would be 11420078, as 1/23/2019 is the min value that is greater than the source date 6/15/2018 that is associated with that user (x). The source dates shown are simply examples and are much more varied in real life.
I am running on Excel 2013 version. As there are dates involved, I can't accomplish my normal method of concatenating the values to make a composite key, especially since I am not looking for exact matches from the reference table but rather the ID of the date that is the MIN date GREATER THAN my row's date.
I have tried Index-Match with IF, but I am getting N/A values and not sure what's going wrong. I am not an experienced user with Index-match, and am having trouble applying non-exact examples to my current situation.
Edit: Per advice given by Scott, I have modified the query to be as such:
=INDEX($R$2:$R$9120,MATCH(MIN(IF(($P$2:$P$21986=M2)*($Q$2:$Q$21986<=L2),L2-$Q$2:$Q$21986)),INDEX(($P$2:$P$21986=M2)*($Q$2:$Q$21986<=L2)*(L2-$Q$2:$Q$21986),0),0))
Though it is no longer resulting in NA, it is now giving me the max value'd effective dated row for each ID, rather than the MIN that is GREATER THAN my Source Date field. For example, UserID x is getting a value of 12360373, where it should be getting a value of 11420078.

Spotfire- limiting Information link colum expression

I have a column of data [Sales ID] that bringing in duplicate data for an analysis. My goal is to try and limit the data to pull unique sales ID's for the max day of every month in the analysis only (instead of daily). Im basically trying to get it to only pull in unique sales ID values for the last the day of every month in the analysis ,and if the current day is the last day so far then it should pull that in. So it should pull in the MAX date in any given month. Please how do i write an expresion with the [Sales ID] column and [Date ] column to acieve this?
Probably the two easiest options are to
1) Adjust the SQL as niko mentioned
2) Limit the visualization with the "Limit Data Using Expression" option, using the following:
Rank(Day([DATE]), "desc", Month([DATE]), Year([DATE])) = 1
If you had to do it in the Data on Demand section (maybe the IL itself is a usp or you don't have permission to edit it), my preference would be to create another data table that only has the max dates for each month, and then filter your first data table by that.
However, if you really need to do it in the Data on Demand section, then I'm guessing you don't have the ability to create your own information links. This would mean you can't key off additional data tables, and you're probably going to have to get creative.
Constraints of creativity include needing to know the "rules" of your data -- are you pulling the data in daily? Once a week? Do you have today's data, or today - 2? You could probably write a python script to grab the last day of every month for the last 10 years, and then whatever yesterday's date was, and throw all those values into a document property. This would allow you to do a "Values from Property".
(Side Note: I want to say you could also do it directly in the expression portion with something like an extremely long
Date(DateTimeNow()),DateAdd("dd",-1,Date(Year(DateTimeNow()), Month(DateTimeNow()), 1))
But Spotfire is refusing to accept that as multiple values. Interestingly, when I pull the logic for a StringList property, it gives this: $map("${udDates}", ","), which suggests commas are an accurate methodology, but I get an error reading "Expected 'End of expression' but found ','" . Uncertain if this is a Spotfire issue, or related to my database connection)
tl;dr -- Doing it in the Data on Demand section is probably convoluted. Recommend adjusting in SQL if possible, and otherwise limiting in the visualization

Access Crosstab Report

I am fairly new to access and have a database report issue I can't seem to figure out (even with several posts on the topic :/ )
The database houses audit information from 200+ stores. The audit answers are text, not numeric, and the audit date can be any day. I want to create a report that lists the audit question as row headers, the most recent three audit dates as column headers, and the audit answers as the data.
I have a form that allows the user to select the store, and that feeds the crosstab query. It works, except it does not limit to most recent three dates. The table that feeds the query also lists visit number, so I thought I could do something with the max of visit number but to no avail.
The main issue though is now I cannot get a crosstab report to generate any data. I have found several example pieces of code from back in the day that I have tried, but each tries to generate a row and grand total. Since these are text data fields, the totals will not work and while I have tried removing the pieces of code I think are appropriate, it still does not generate the correct report.
A second option I thought of trying was to export the crosstab query to excel but I am also stuck there.
Any help would be VERY appreciated. Thank you!
Depending on your skill level, this may be difficult. My approach would be a bunch of subqueries, but it won't be pretty. Let's say your stores are uniquely identified by StoreID, your audit dates are Audit Date, and your audit results are in a single text field AuditResults. It'll be up to you to figure out the details, but here's a rough outline:
Get all your data into a single table with 1-3 rows per StoreID (1 per audit date):
Make a simple query that groups by StoreID and returns max (AuditDate). Call it Qry1a.
Join Qry1a back to the audit table to return the results from the most recent audit. Include a daterank column that is hardcoded to 1. Call it Qry1b.
Repeat a and b two more times to get the results from the 2nd and 3rd most recent audits (You can left join onto Qry1 and Qry2 to remove those results). Call those Qry2b and Qry3b.
Using inner joins with your source table and Qry1b,Qry2b, and Qry3b, make a query that return a max of 3 rows per StoreID.
With this new table, make a new query and group by StoreID:
For the first columns, you'll use something like LastAudit: max(iif(DateRank=1,AuditResults,""))
Repeat the previous step to get the next 2 audits changing daterank to 2 and 3 respectively.
The advantage of this approach is that it can handle stores with less than 3 audits or if you have a constantly changing list of stores (because storeIDs aren't hardcoded anywhere).

Get the average monthly value from 2 SP List columns and display in new column

I need to calculate the average value for each month. Currently I have 2 columns "DATE" (date value e.g 01/01/2010) and AccOpen (number value). So for all dates within January I need to return the average value of all numbers contained in the corresponding AccOpen rows for January dates.
Is it possible to use the CALCULATED option and input a FORMULA that will return the average for all itmes within each months period (when adding a column to the list ?
DATE ACCOPEN AVERAGE
01/01/2010 2 2
02/01/2010 2
03/01/2010 2
04/01/2010 2
01/02/2010 2 2
02/02/2010 2
03/02/2010 2
04/02/2010 2
You're not going to be able to do this OOTB without writing event receiver code (or other custom code running in a batch mode).
To get you started
MSDN - How to: Create an Event Handler Feature
Event Handlers : Everything you need to know...
This will need to hook into the list item update and then consolidate your list into a separate summary list with the calculations you need.
The brute force approach would be to run the calculation afresh for every item in the group when an item is inserted/updated.
A smarter approach would be to just update the delta (the difference between the old and the new record) which is easier to do if you store components of the calculation - so in your case
Month - NumRecords - TotalValue
and work out the Average on the fly (as its easy to delta the NumRecords/TotalValue but impossible to apply it directly to the average)
One 3rd party web part which may fit your need is PivotPoint - it allows you to do things like sum/count/avg over groups like Month & Year (disclaimer - I work for the company)
It is not possible to query anything other than the current item when creating a formula field.
The only way to do this is to create custom code either within an event handler for the list or external code that processes items in the list and updates a "average" field when required.
Create a calculated field to give you the year and month, for example: 2011-07. Then modify your list view to group on the calculated field. When editing your view, there is also an option to display totals, I believe you can set this to average for your AccOpen column. If you're not interested in the details, you can choose to collapse all groups by default.

Resources