Getting max date of values based on another column - date

The problem I am trying to solve is I need to fill in column 'F' with each value's respective max date, or latest date.
Here is a screenshot of what it should look like:
The solution is to the right of it. I did it manually for demo purposes but I need to do it for a much larger dataset, and need a more efficient way of doing it.
Can you please help me with the proper formula here?

if latest is based on the row use:
=SORTN(SORT({B2:B, A2:A}, ROW(A2:A), 0), 9^9, 2, 1, 1)
if latest is based on the date use:
=SORTN(SORT({B2:B, A2:A}, A2:A, 0), 9^9, 2, 1, 1)

Related

Group by month using cell above filtered cells

I have a spreadsheet that looks like this:
https://docs.google.com/spreadsheets/d/1b29gyEgCDwor_KJ6ACP2rxdvauOzacDI9FL2K-jgg5E/edit?usp=sharing
I have two columns I'm interested in, Date and Count. Every few dates, there will be a "TOTAL" line where all the Counts corresponding to that TOTAL will be summed.
I want an output that looks like the cells to the right, where all the TOTAL counts are summed according to month. The problem lies in that Column A has only the date or TOTAL, in separate rows, and this layout can't be changed, leaving me thinking I need to reference the cell directly above TOTAL in column A, which has the correct month I want to group that TOTAL by.
The reason why I can't just filter column A by date range is because of inconsistent use, where sometimes the count data is only entered in the TOTAL row.
I've scoured the internet exploring FILTER, INDIRECT, QUERY, SUMIFS, etc... but can't find exactly how to do this.
I can easily filter column B where A:A="TOTAL", but what I think I am needing to do after that is use each cell above where A:A="TOTAL" as a range for the month criteria, somehow using what I found here: https://exceljet.net/formula/sum-by-month, expressed by ">="&D3 and "<="&EOMONTH(D3,0).
Any help or alternatives would be appreciated. Thank you.
or a different (offset) approach:
=QUERY(FILTER({EOMONTH(INDIRECT("A1:A"&ROWS(B2:B)), 0), B2:B}, A2:A="total"),
"select Col1,sum(Col2)
group by Col1
label sum(Col2)''
format Col1'mmmm'", 0)
Query formula is great for these kind of situations but looking at it by month will introduce issues if you plan on looking at multi-year data:
=arrayformula(QUERY(QUERY({row(A:A),TEXT(A:A,"MMMM"),B:B},"SELECT max(Col1),Col2,sum(Col3) where Col3 is not null group by Col2 order by max(Col1) label Col2 'Month', sum(Col3) 'Count'"),"SELECT Col2,Col3"))
try:
=ARRAYFORMULA(QUERY({IF((B2:B="")*(A2:A=""),,VLOOKUP(ROW(A2:A),
IF(A2:A<>"total", {ROW(A2:A), DATEVALUE("01/"&MONTH(A2:A)&"/2000")}), 2, 1)),
IF(A2:A= "total", A2:A, ), B2:B},
"select Col1,sum(Col3)
where lower(Col2) = 'total'
group by Col1
label sum(Col3)''
format Col1'mmmm'", 0))

Get the name of "named data range" from a cell in Google Sheets

I have a range of data that I want to use vlookup on. I named the range as "june_salaries". The goal is to generate payslips for each employee based on the data range (june_salaries).
My query is that is there a way to instead of writing something like
=VLOOKUP($B$6,june_salaries,4,0)
I can simply refer to a single cell for the "named range"? For example, let's say I put the text "june_salaries" in cell A1, and when I use vlookup, for the range of data I will simply refer to that cell.
The reason why I want to do that this way is the salary sheet changes each month and so is the name of the range. But if I can refer the data range in a single cell, I can simply change the name of the month from June to July or anything.
Hope the query is clear. Please let me know if further information would be required.
as mentioned, you can use INDIRECT to reference a cell value/string and reflect it into a formula
=VLOOKUP(B6, INDIRECT(F1), 4, 0)
array formula (if needed) of that would be:
=ARRAYFORMULA(IFERROR(VLOOKUP(B6:B, INDIRECT(F1), 4, 0)))
HOWEVER, you could automate it (if you plan to edit F1 cell once per month for each month)
=VLOOKUP(B6,
INDIRECT(LOWER(TEXT(DATE(2000, MONTH(TODAY())-1, 1), "mmmm"))&"_salaries"), 4, 0)
eg. this month it will return you june_salaries, next month it will return you july_salaries, etc.
Assuming june_salaries in F1. Wrap your named range name in INDIRECT:
=VLOOKUP($B$6,indirect(F1),4,0)

Pentaho Spoon:How to modify all the values of a column?

I am new to Pentaho spoon and even after a long time of research, didn't resolve my problem:
I have a table, and want to multiply by 3 all the values of few columns.
For instance, if I have inside of a column (5, 10, 3) then it becomes (15, 30, 9).
I don't want to have a new field if it's possible, just want to replace those values.
The calculator option requires an another field and I only need one constant. Tried with Modified javaScript value, it just sets everything to zero. Can anyone help me?
Thanks!!
You can use the Formula step to override / replace a value from an existing column. Keep in mind that for this to work, the Value Type's of both the origin and target columns must match, INT/INT, String/String and so on.

rounding up to the next whole integer and adding days onto a fixed date - Crystal Reports

I have a result from a simple formula of "1.46". I require part of a formula to round the 1.46 to the next integer, for this example it would become "2.00".
I have a fixed date lets say "23/07/2014", If the previous example stated how many days would need to added onto the fixed date, how would I go about this?
I have tried to keep it as simple as possible to give clarity of what I require. If you need any more information, please ask.
Many thanks
For your first one you can use Round function.
I didn't get the second requirement... any example will be useful
Edit------------------------------------------------------------
Let the round value is stored in a variable Store. Use below function to add that to date.
DateAdd("d", Store, <<Datefieldhere>>)

Working with a delimited list of items in a Tableau field

I am preparing a data visualization in Tableau.
I have some data that can be simplified like this:
Name, Score, Tag
Joe, 5, A;B
Phil, 7, D
Quinn, 9, A;C
Bill, 3, A;B;C
I would like to generate a word cloud on the Tag field that counts
occurances of each item A,B,C. So I need to generate this:
A,3
B,2
C,2
D,1
In other words, I need help working with a field that contains a list of delimited values.
In the example data ; is the delimiter, but it could be anything.
I would like the word cloud to update as the user
applies filters, e.g. dragging a slider to set score > 5.
So the tag count has to be done on the fly.
I'm pretty sure I'll need to use field calculations and table calculations..?
Possibly I'll need to have a separate table tracking the tags..?
I have no problem building the word cloud and other viz elements.
What I'm looking for help with is parsing the delimited list field and
calculating the tag counts.
I do have full control over the source data, so if there is an easier way to
do this by reorganizing the schema, I'd be glad to do that. I thought of breaking
the field up into spearate tag1, tag2, tagX fields and trying to count over the
separate fields... but not sure if this is any simpler.
Thanks for any tips.
Another (probably better in your case) approach is to reshape the data before feeding it to Tableau. Tableau works best with normalized data.
Preprocess it to look like:
Name, Score, Tag
Joe, 5, A
Joe, 5, B
Phil, 7, D
Quinn, 9, A
Quinn, 9, C
Bill, 3, A
Bill, 3, B
Bill, 3, C
At that point, the standard Tableau word cloud charts should work well, and it will scale easily as you add more tags and data.
Reshaping data to normalize it prior to analysis with Tableau is a pretty standard step. Sometimes you can do it automatically, say with custom SQL, but often you'll have to use some sort of script first. If your data comes from Excel, Tableau has a plug in that can help with reshaping data. Look for it on the Tableau knowledge base.
Here's an approach that would be tolerable if you had a fixed set of 3 or 4 tags. Since you have closer to 50K possible tags, it's not a feasible approach for your problem as is. But maybe it will give you an idea. Similar approaches can be used to solve different kinds of problems in Tableau, so its a useful trick to know.
For each tag, create a boolean calculated field that returns 1 if the current row contains that particular tag and null otherwise (or whatever the condition is you want to detail)
For example, define a calculated field called Tag_A defined as:
if contains(Tag, "A") then
1
end
Similar, define calculated fields Tag_B, Tag_C etc
So far it's easy.
Then you can use those fields in other calculations to count the number of records that contain tag A, filter to only those that contain A, use the calculated field on the condition tab when defining sets that are computed dynamically by a formula ... Of course, the low level calculated field function can be more complex, say checking for the presence of at least 2 fields out of a list for example.
If nothing else, this approach sometimes lets you break complex problems into bite sized pieces.
Unfortunately, hard coding calculated field names won't scale to 50K tags. For that, you probably want to reshape your data.