Copy and Filter out selected fields from 2 tabs in the Same Gsheet to another Tab with Fraud = 'Yes'
I have 2 sets Tabs in the Same Gsheet with different information. I would like to copy them into another tab with Fraud ="Yes". I have an example with formulas in Combine Example from Stall A Example and Stall B Example with some help previously. When I tried to replicated into my actual data (Combine NSU and ACH ) set I can't do it.
Can someone please help and guide on this.
https://docs.google.com/spreadsheets/d/1N35wUB-a7hDHFTzdhajlaCTJf_Ce34Ql3Miwq51JCqY/edit?usp=sharing
Whenever it is Fraud = "Yes", it extracts the necessary information from NSU Tab and ACH Tab with has Fraud = Yes into Combine NSU and ACH Tab
#=SORT(
LAMBDA(DATA,
LAMBDA(DATE,TYPE,AMOUNT,FRAUD,ID,ERP
FILTER({TEXT(DATE,"dd/mm/yyyy"),TYPE,AMOUNT,FRAUD,ID,ERP},FRAUD="YES")
)(INDEX(DATA,,1),INDEX(DATA,,2),INDEX(DATA,,8),INDEX(DATA,,13),INDEX(DATA,,15),INDEX(DATA,,16))
)({'NSU'!A2:P27;{'ACH'!A2:A8, 'ACH'!B2:B8,'ACH'!N2:N8,'ACH'!L2:L8,'ACH'!F2:F8,'ACH'!H2:H8 }})
,1,TRUE)
Code:
Output:
Get all data of sheet NSU and ASH, and re-arrange their orders by QUERY.
Group them up with another QUERY to filter the data you want such as Col4 = 'Yes'.
All the formating and sort can also be done with query.
=ArrayFormula(
LAMBDA(NSU,ACH,
QUERY({NSU;ACH},
" WHERE Col1 IS NOT NULL "
&" AND Col4 = 'Yes' "
&" ORDER BY Col1 ASC"
&" LABEL Col1 'Date',Col2 'Type',Col3 'Amount',Col4 'Fraud',Col5 'ID',Col6 'ERP' "
&" FORMAT Col1 'yyyy-mm-dd' "
)
)(
LAMBDA(COLS,
QUERY({NSU!$A:$P},
" SELECT "&JOIN(",","Col"&COLS)
&" LABEL "&JOIN(",","Col"&COLS&" '"&REPT(" ",COLS)&"'"),1)
)({1,2,8,13,15,16}),
LAMBDA(COLS,
QUERY({ACH!$A:$N},
" SELECT "&JOIN(",","Col"&COLS)
&" LABEL "&JOIN(",","Col"&COLS&" '"&REPT(" ",COLS)&"'"),1)
)({1,2,14,12,6,8})
)
)
Well, in-case you really want to have the ability to add some input fields in-between the output QUERY.
The answer is you can't, but also you can.
Basically, you cannot insert anything in-between any kind of array outputs in google spreadsheets, the array-formula will return an error '#ref' mentioning that there are other values inside the output range which fail it from showing the output, BUT...
you can always get around this issue by simply seperate the output array by an other QUERY, such as:
This simple array in google sheet will reference range A1:C10 and place the data into where-ever you type this formula into, which output a 10 rows by 3 columns array.
={A1:C10}
We assumne that you put this in cell 'E1', that makes the output covers range 'E1:G10'.
If you what to have a column of fields which allow you to input new data in-between the output range, for example, you want to add a new column in F:F.
In that case, you can put 2 formula seperatly into cell 'E1' and cell 'G1', which contains the following formulas:
in cell 'E1':
=QUERY({A1:C10},"SELECT Col1")
in cell 'G1':
=QUERY({A1:C10},"SELECT Col2,Col3")
Since the output arrays are seperated, that makes the column(s) between the column E and column G a normal empty column, which allows you to input anything into the cells.
The beauty of QUERY function is that you can select any column(s) of a given reference array as an output.
In this case the output data will be seperated into 2 parts, one contains only the first column of the reference, the second one contains the rest of them.
It doesn't matter how many empty columns you insert between the 2 outputs since they are 2 outputs of one identical reference.
The draw back is, if your reference data are results of calculations, the sheet will have to do all those calculations two times, even if they gives the same results, which is why I say this can and will slow things down and are not very recommended.
I have a table with 3 columns: CLIENT_ID, STORE_ID and MADE_PURCHASE. Basically I'm trying to get a list of CLIENT_ID and an array of STORE_ID where a customer made a purchase. For the following data, here is the expected result:
DATA:
CLIENT_ID
STORE_ID
MADE_PURCHASE
1
a
YES
1
b
YES
1
c
YES
2
a
YES
2
b
NO
2
c
YES
3
a
NO
3
b
NO
3
c
NO
Expected result:
CLIENT_ID
STORE_ID
1
a,b,c
2
a,c
I was able to achieve the desired result by creating a query to filter out lines where MADE_PURCHASE = 'NO'. Then I created a list in the report. The first column is CLIENT_ID then I insert a repeater in the second column that contains STORE_ID.
The problem is that the repeater slows my report by a factor about equal to the number of CLIENT_ID retrieved. For example if I run the query without a repeater and it returns 10 unique CLIENT_ID in 10 seconds, then adding the repeater slows the report to 100 seconds. As soon as I enter more than a few hundred CLIENT_ID in the prompt the report takes multiple hours to run.
I tried editing the master-detail relatioship between the list and the repeater without much change. Anyone has any idea how I could make it run faster?
P.S. I know the desired output format is not ideal but the goal is to mimic a legacy report that was built on excel using concatenate on STORE_ID, as such, the client wants to keep the original format.
You can try to edit the FM - Governors with the parameter (DQM) Master-Detail Optimization with "Cache Relaional Detail Query".
I would like to pull all ingredients that are unavailable (they still visible but in grey: an example with the
on a Deliveroo page.
All ingredients are on a
.
I would like to get a google sheet with all missing items per day.
Does anyone have an idea of how to build that?
The link to the Deliveroo page is:
https://deliveroo.co.uk/menu/london/soho/honi-poke?day=today&postcode=W1T1DE&time=ASAP
=ARRAYFORMULA(REGEXEXTRACT(REGEXREPLACE(QUERY(IMPORTDATA(
"https://deliveroo.co.uk/menu/london/soho/honi-poke?day=today&postcode=W1T1DE&time=ASAP#"),
"select Col1 where Col1 contains'item--unavailable'"),
"\>|\<|\/|\""", ""), "0.1(.*)spanh6"))
I'm trying to create an area chart using cfchart, but not sure how to go about it. I'm doing a query of all comments in a table and want to show time period (days or months on x-axis) and output number of comments as they are created. Here's the comment query:
<cfquery name="qGetComments" datasource="#session.datasource#">
SELECT PersonFirstName
, PersonLastName
, PersonZip
, CommentCode
, refTopicID
, tbComment.CommentID
, tbComment.CreateDateTime
FROM tbPerson
JOIN tbComment ON tbPerson.PersonID = tbComment.PersonID
</cfquery>
From here, I'm not sure the values to put in the cfchart to output the area chart the way I want. Something like this?
<cfchart chartWidth="400" show3D="yes">
<cfchartseries type="area" query="qGetComments"
valueColumn="CommentID"
itemColumn="CreateDateTime" />
</cfchart>
A simple way to group the records by date in Server 2008+ above is cast the datetime column to a date. Then use simply use the "CommentDate" column as the chart item and "NumOfComments" for the value:
SELECT CONVERT(DATE, tbComment.CreateDateTime) AS CommentDate
, COUNT(*) NumOfComments
FROM tbPerson INNER JOIN tbComment ON tbPerson.PersonID = tbComment.PersonID
GROUP BY CONVERT(DATE, tbComment.CreateDateTime);
You can make the chart labels a little more user friendly by formatting the date within the SQL (see cast and convert). Just be sure to order the results by the date value, and not the formatted string. Otherwise, the chart labels may not appear in proper chronological order (it is a common mistake):
--- format as: Mon dd, yyyy
SELECT CONVERT(VARCHAR, tbComment.CreateDateTime, 107) AS CommentDateString
, COUNT(*) NumOfComments
FROM tbPerson INNER JOIN tbComment ON tbPerson.PersonID = tbComment.PersonID
GROUP BY CONVERT(VARCHAR, tbComment.CreateDateTime, 107)
ORDER BY CONVERT(DATE, CONVERT(VARCHAR, tbComment.CreateDateTime, 107), 107)
SQLFiddle
As an aside, if HTML charts are an option, you might look into Scott's suggestion. Generally CFChart is fine for simple cases, but once you start to customize the appearance (which invariably happens), you are usually better off using the underlying tools directly.
I am a DBA of 7 months so please bear with me. I am needing to write a code that will find a particular ProductIdentifier. When this particular ProductIdentifier is found, 1. I need to grab this ProductIdentifier. 2. I need to go 2 rows up and place that ProductIdentifier in the field that is 2 rows above it.
Here is my code(everything is sorted properly already in this table)
SELECT
SipID,
SaleInvoiceID,
AssociationNumber,
Priority,
TotalPrice,
TotalCost,
SerialNumber,
ContractNumber,
ActivatedThroughPAW,
DateCreatedatMidnight,
ReceivedDate,
InvoiceIDByStore,
Location,
ProductIdentifier,
Description,
ShortDescription,
CategoryName,
RevenueStreamID,
RevenueType
FROM REVISEDTABLE.
I will better show you what needs to be done ![enter image description here][1]
ProductIdentifier
AWUPG2001RGP -- replace this product identifier with the 'AWRPNS000%'
POSC0021PRW
AWRPNS000343 --take this product identifier
What I need for this code to do is this: whenever I find any ProductIdentifier like 'AWRPNS000%', I need for the query to take this and go 2 rows up and replace whatever ProductIdentifier is in this with 'AWRPNS000%'. I then need to insert the results into a table. I believe the best thing to do is to select the ProductIdentifier row again and give it an alias. This will be the row that I need to transform. I can then do a comparison to see if things worked out. I do not know how to write the code to do the actual grabbing of the ProductIdentifier and going up 2 rows and replacing it, so any help or input would be greatly appreciated.
So what does two rows up mean. Why is it two rows up.
e.g.
ID Class Type Date
1 1 2 20/12/2012
2 1 2 21/12/2012
3 1 2 22/12/2012 *
ie yes ID is two rows up but that's because The records are in ID and date order and there are at least three of them.
If you can come up with that rule e.g.
Select * From SomeTable Where Class = 1 and Type = 2 And Date = 20/12/2012
Then all your problems go away...