I have a table which I would like to return in its entirety but filtered by column H with the maximum date as rows have duplicate account numbers with different dates.
https://docs.google.com/spreadsheets/d/1x3hYy1igiL3_lqhFE3IwrQNFbOjdpXRtHLAbOXB2BE4/edit?usp=sharing
I'm using this query right now, but clearly I'm overlooking something, can anyone help, please?
=QUERY(B3:I12, "Select *, Max(H) WHERE B is not null Group by C")
correct syntax would be:
=QUERY(B3:I12,
"select B,C,D,E,F,G,H,I,max(H)
where B is not null
group by B,C,D,E,F,G,H,I")
but you probably need this:
={B3:I3; SORTN(SORT(B4:I, 7, 0), 99^99, 2, 2, 1)}
The final formula was ={DataTable;SORTN(SORT(Data,17,0),99^99,2,2,1)}
DataTable is the headings and Data is the dataset. Out of 14,000 lines this filtered down to around 7,000 lines of unique rows with the highest (Maximum) date.
Related
I have a table of data that is formatted like this
and i would like to extrapolate how many ASSIGNMENTS, PROJECT, and PERMITS total on all the engineers.
Im having problem because this does not really deal with numbers so no mathematical formula i cant think of will work.
Here is a sheet link of the image above.
Here is my idea of doing it but i have no idea how to code this into a formula on excel.
The formula will look for the key word, assignment, project, or permit and will then check if the next 2 column have contents in them if so then it is a plus 1, if the cell below the keyword(assignment,proect,or permit) is empty check if there is contents to 2 column beside the empty cell if empty then stop, if there is plus 1, if a plus 1 check again for an empty cell below that one rinse and repeat.
try:
=ARRAYFORMULA(QUERY(REGEXREPLACE(IF(B3:B="",, VLOOKUP(ROW(A3:A), IF(A3:A<>"", {ROW(A3:A), A3:A}), 2, 1)), "s$", ),
"select Col1,count(Col1) where not Col1 matches '^Enginee.+' and Col1 is not null group by Col1 label count(Col1)''"))
update:
=ARRAYFORMULA(QUERY(REGEXREPLACE(IF(Sheet1!B3:B="",, VLOOKUP(ROW(Sheet1!A3:A), IF(Sheet1!A3:A<>"", {ROW(Sheet1!A3:A), Sheet1!A3:A}), 2, 1)), "s$", ), "select Col1,count(Col1) where Col1 matches 'Assignement' and Col1 is not null group by Col1 label count(Col1)''"))
Seeking assistance regarding how to structure a query that will be processing data from multiple sheets (ie tabs), however both sheets have different data structure.
The first query (below) queries a tab that contains all of my expenses itemised. This sums them by month.
=query(Expense_Data, "SELECT C, SUM(Q) where T Matches 'Expense' GROUP BY C ORDER BY C desc limit 3 label SUM(Q) 'Expenses'",1)
Example Data Output Below
Date
Expenses
01/01/2021
-$1000
01/02/2021
-$1500
01/03/2021
-$1000
What I am seeking is to query another sheet which contains data (located in column G) that I wish to return based upon the date returned from the first query (located in column A), which I will then calculate the difference between. My issue is associating the 2 data sets together. Any support would be greatly appreciated!
Date
Expenses
Budget
Difference
01/01/2021
-$1000
-$2000
-$XXXX
01/02/2021
-$1500
-$1500
-$XXXX
01/03/2021
-$1000
-$1500
-$XXXX
try:
=QUERY(Expense_Input,
"select C,sum(Q)
where T matches 'Expense'
group by C
order by C desc
limit 3
label sum(Q) 'Expenses', C'Month'
format C'mmmm yyyy'", 1)
then:
={"Budget"; ARRAYFORMULA(IFNA(VLOOKUP(TO_TEXT(A13:A),
{'Expense Lookup (Monthly)'!C:C&" "&'Expense Lookup (Monthly)'!D:D,
SUBSTITUTE('Expense Lookup (Monthly)'!G:G, "$", )*1}, 2, 0)))}
and:
={"Difference"; INDEX(IF(A13:A="",,C13:C-B13:B))}
update
in one go:
=ARRAYFORMULA(QUERY({QUERY(Expense_Input,
"select C,sum(Q)
where T matches 'Expense'
group by C
order by C desc
limit 3
format C 'mmmm yyyy'", 1), IFNA(VLOOKUP(TEXT(INDEX(QUERY(Expense_Input,
"select C,sum(Q)
where T matches 'Expense'
group by C
order by C desc
limit 3",1),,1), "mmmm yyyy"),
{'Expense Lookup (Monthly)'!C:C&" "&'Expense Lookup (Monthly)'!D:D,
SUBSTITUTE('Expense Lookup (Monthly)'!G:G, "$", )*1}, 2, 0))},
"select Col1,Col2,Col3,Col3-Col2
label Col1'Month',Col2'Expenses',Col3'Budget',Col3-Col2'Difference'"))
I have 4 sheets named: STATS, SHEET01, SHEET02 and SHEET03.
SHEET01, SHEET02 and SHEET03 look exactly the same like the picture below but with different dates and percentages.
In cell A1 of the STATS sheet I have the following formula:
=IFERROR(ArrayFormula(AVERAGEIFS(SHEET01!B2:B,month(SHEET01!A2:A),2,year(SHEET01!A2:A),2020)))
This formula returns the average percentage of February 2020.
This formula clearly only works with SHEET01 and I can't figure out how to make it also take the averages of SHEET02 and SHEET03.
I have tried:
=IFERROR(ArrayFormula(AVERAGEIFS(SHEET01!B2:B,SHEET02!B2:B,SHEET03!B2:B,month(SHEET01!A2:A,SHEET02!A2:A,SHEET03!A2:A),2,year(SHEET01!A2:A,SHEET02!A2:A,SHEET03!A2:A),2020)))
UPDATE
Now using the following query:
=query({'SHEET01'!A:B;'SHEET02'!A:B;'SHEET03'!A:B},"select avg(B) Where A is not null and A>=date'2020-01-01' and A<=date'2020-01-31'")
This outputs the following error:
Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: B
try in B2 of stats sheet if A2:A contains dates:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A,
QUERY({SHEET01!A2:B; SHEET02!A2:B; SHEET03!A2:B},
"select Col1,avg(Col2)
where Col1 is not null
group by Col1
label avg(Col2)''"), 2, 0)))
or use only this to get the full summary:
=QUERY({SHEET01!A2:B; SHEET02!A2:B; SHEET03!A2:B},
"select Col1,avg(Col2)
where Col1 is not null
group by Col1
label avg(Col2)''")
note that you might need to format dates via 123... button if your dates will outputted as 4000+ numbers
I'm trying to only show values from a list for a given month, based on the desired month selected in a drop down.
Column B, C & D I have a list of items for a given month, each column representing a different month.
Row 2, 3, 4 is the expected quantity sold for each month.
I would like a drop down to be selected, picking a specific month, then showing how many of each item are expected to be sold.
if the dropdown is like:
try:
=INDIRECT(ADDRESS(2, MATCH(B7, 1:1, 0))&":"&
ADDRESS(5, MATCH(B7, 1:1, 0)))
or try:
=QUERY(TRANSPOSE(QUERY(TRANSPOSE(B1:Z5),
"where Col1 = date '"&TEXT(B7, "yyyy-mm-dd")&"'")),
"offset 1", 0)
Alternatively you can use this:
=QUERY({A133:D136},"Select Col" & filter(COLUMN(B132:D132),B132:D132=H132))
Just using filter like this:
=filter(B133:D136,B132:D132=H132)
I have the following Matrix in SSRS 2008 R2:
What I would like to do is only show columns where the "FTE" row has a value. (Marked with red circles). I've tried the filter and show/hide options based on expressions in the Column Properties, but I can't figure out how to only reference the rows when "category"="FTE". My data looks like this:
tblPhysicians
employee_id last_name ...
102341145 Smith
123252252 Jones
tblPhysiciansMetrics
id fy period division_name category_name employee_id
123 2014 1 Allergy Overhead 123456
124 2014 1 Allergy Salary 125223
125 2014 1 Allergy FTE 1.0
query
SELECT * FROM
tblPhysicians
INNER JOIN tblPhysicianMetrics
ON tblPhysicians.employee_id = tblPhysicianMetrics.employee_id
WHERE
tblPhysicianMetrics.division_name = #division_name
AND tblPhysicianMetrics.fy = #fy
AND tblPhysicianMetrics.period = #period
Notice that the rows in my Matrix is just the category_name, so I can't just hide when category_name = "FTE", that's not really what I want. What I really need is some way of saying, "For rows where category_name = "FTE", if the value is not set, don't show that column". Is this possible?
An alternative would be to not even get those in the query, but as with the filtering of the matrix, if I simply add "AND tblPhysiciansMetrix.category_name = 'FTE'" to the WHERE clause, my entire data set is reduced to only those records where category_name is FTE.
Any help is much appreciated!
Update: added definition of Matrix to help:
You need to set the column visibility with an expression that checks all underlying data in the column for the FTE category.
I have a simple dataset:
And a simple matrix based on this:
Which looks exactly as you expect:
So in the above example, we want the Brown column to be hidden. To do this, use an expression like this for the Column Visibility:
=IIf(Sum(IIf(Fields!category_name.Value = "FTE", 1, 0), "last_name") > 0
, False
, True)
This is effectively counting all the fields in the column (determined by the last_name scope parameter in the Sum expression) - if this is > 0 show the column. Works as required:
CAVEAT I'm not 100% sure how you are grouping this data in the matrix. It isn't 100% clear from your description. Let me know why this doesn't work (if it doesn't and I'll update my answer accordingly.
I've replaced the column employee_id with the name value for my answer, to keep my explanation simple.
Add this nested IIF() to the visibility property of your Matrix's column.
=IIF(Fields!category_Name.Value="FTE" ,IIF( Fields!value.Value >= 0, True,False),false)
It will check both the value of the the category and the 'FTE' in that row's cell.