I Have a table in my spreadsheet like this
FEB MAR APR MAY
10 14 7 13
12 9 8 19
15 11 14 16
And I want to use this info in another table. What I want to accomplish is in this another table compare two months by getting this info with the name of the month.
FEB APR
10 7
12 8
15 14
What I did was
=QUERY(AnotherTable!1:1001; "SELECT * WHERE Row2 = 'FEB'")
But it didn't seems to work.
Any thoughts?
You might be able to use a FILTER formula instead:
=FILTER(AnotherTable!1:1001;AnotherTable!2:2="FEB")
or to return both months:
=FILTER(AnotherTable!1:1001,((AnotherTable!2:2="FEB")+(AnotherTable!2:2="APR")))
Use TRANSPOSE built-in function two times, the first to flip the source data, the second to flip the result, and instead of referencing rows, the formula should reference columns.
The resulting formula is
=TRANSPOSE(QUERY(TRANSPOSE(A:D),"Select * where Col1='FEB' OR Col1='APR'"))
Applying the above formula to the following source data
FEB MAR APR MAY
10 14 7 13
12 9 8 19
15 11 14 16
will return the following result
FEB APR
10 7
12 8
15 14
Related
I am new in using Cognos and I have data for the overall project, and I need to create some kind of table or cross tab may be to count the overall project of each year and how many of them are active, canceled and inactive
I have tried using a cross tab but no success.
ProjectId Status Date
1589 Active 8/29/2018
1566 Inactive 4/17/2018
1042 Cancelled 1/6/2014
1374 Completed 1/20/2015
1543 Completed 8/4/2014
1065 Cancelled 7/15/2014
1397 Completed 10/1/2012
1520 Inactive 4/13/2017
1420 Completed 1/1/2015
1443 Completed 1/1/2015
1048 Cancelled 10/16/2014
1002 Active 2/6/2017
1357 Completed 1/19/2017
1606 Active 11/6/2018
Output should look like this
New Projects Active Cancelled/Terminated/Inactive Carried Forward
2013 32 45 4 11 30
2014 45 75 17 14 44
2015 46 90 25 21 44
2016 30 74 27 10 37
2017 82 119 11 26 82
2018 86 168 29 24 115
2019 23 138 9 4 125
Going with -- project Id, status, Date
The ideal scenario is we have a data item for year. If not, to get the year
extract(year, Date)
Calculation data items: for each count
For example, this is for active
if (status = 'Active')Then(1)Else(0)
For properties
Make sure the aggregation is set to total
Adding the column should give you the count
The data structure is as follows:
Cli_ID M_YR trans-Date First_Trans
1004525 Oct 17 30-Oct-17 20-Sep-17
1004570 Oct 17 02-Oct-17 30-Aug-17
1004570 Oct 17 05-Oct-17 30-Aug-17
1004570 Oct 17 10-Oct-17 30-Aug-17
1004570 Oct 17 11-Oct-17 30-Aug-17
1004570 Oct 17 12-Oct-17 30-Aug-17
1004570 Oct 17 13-Oct-17 30-Aug-17
1004570 Oct 17 17-Oct-17 30-Aug-17
1004570 Oct 17 19-Oct-17 30-Aug-17
1004570 Oct 17 23-Oct-17 30-Aug-17
1004570 Oct 17 24-Oct-17 30-Aug-17
1004570 Oct 17 25-Oct-17 30-Aug-17
1143578 Oct 17 13-Oct-17 07-Sep-17
1143578 Oct 17 18-Oct-17 07-Sep-17
1143578 Oct 17 19-Oct-17 07-Sep-17
I need to identify all clients who have had at least one transaction per month. I am thinking, based on their first transaction date, calculate how many month they should have had at least one transaction for (Count_month) (eg., if client first transaction is Sept 2017, so from October 2017 to June 2019, the number of month they need to have at least one transaction in is 21).
And then create another counter to loop through each M_YR (month, year), and add 1 if a unique client had a transaction in a given Month-year (Count_client)...(eg., if client had at least one transaction a month from October 2017 to June 2019, the counter would be 21)
If I compare these two variables (Count_client and Count_month), if Count_client < Count_month then i will know this client did not have at least one transaction per month.
Does this method work? is there an easier way to do this? I feel this is probably not the simplest solution but I am currently out of ideas..
To calculate the number of months between first transaction and present date you can use:
compute Months_since_1st = datediff($time, First_Trans, "months").
(the $Time expression will use present date in calculation - you can replace that with any other date).
To calculate the number of months that had any transaction:
dataset name orig.
* identifying every month/year that had transactions - per client.
dataset declare agg1.
aggregate out=agg1 /break=Cli_ID M_YR /n=n.
dataset activate agg1.
* counting them for each client.
dataset declare agg2.
aggregate out=agg2 /break=Cli_ID /Nmonths_with_transactions=n.
* attaching the results back to original data.
dataset activate orig.
match files /file = * /table = agg2 / by Cli_ID.
I have a time series with temperature measures every 5-minutes over ca. 5-7 days. I'm looking to set the correlation structure for my model as I have considerable temporal autocorrelation. I've decided that moving averages would be the best form, but I am unsure what to specify within the correlation = corARMA(q=?) part of the model. Here is the following output for ACF(m1):
lag ACF
1 0 1.000000000
2 1 0.906757430
3 2 0.782992821
4 3 0.648405513
5 4 0.506600300
6 5 0.369248402
7 6 0.247234208
8 7 0.139716028
9 8 0.059351579
10 9 -0.009968973
11 10 -0.055269347
12 11 -0.086383590
13 12 -0.108512009
14 13 -0.114441343
15 14 -0.104985321
16 15 -0.089398656
17 16 -0.070320370
18 17 -0.051427604
19 18 -0.028491302
20 19 0.005331508
21 20 0.044325557
22 21 0.083718759
23 22 0.121348020
24 23 0.143549745
25 24 0.151540265
26 25 0.146369313
It appears that there is highly significant autocorrelation in the first ca. 7 lags. See also the attached images: 1[Residuals] & 2[Model]
Would this mean I set the correlation = corARMA(q=7)?
Currently I have a scope that pulls back my records in the following standard order:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
and it is converted in to a html block that's laid out as so:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
I want a html block that's laid out like so:
1 6 11 16
2 7 12
3 8 13
4 9 14
5 10 15
So I think I need to pull the records back in the following order - (records offset by the number of rows)
1 6 11 16 2 7 12 3 8 13 4 9 14 5 10 15
Any idea what is the neatest way to do this in Rails / ActiveRecord?
You must know how many columns you want to eventually render. I think this must work for you:
columns = 5
MyModel.order(:id).in_groups_of(columns).transpose
And you get an array of lines, each one with an array of records.
If you want an unique array you can add .flatten at the end.
Can't do that with AR ordering! You will have to do that in your controller or the view.
below is my string
local Amount =[[
Customer Details Net Amount
# Seq Name
Amount NTR
1 CDABCDEFGHIJ00564
0,1234
2 CDABCDEFGHIJ00565
0,0361
3 CDABCDEFGHIJ00566
0,0361
4 CDABCDEFGHIJ00567
0,0722
5 CDABCDEFGHIJ00568
0,0000
6 CDABCDEFGHIJ00569
0,0000
7 CDABCDEFGHIJ00570
0,0000
8 CDABCDEFGHIJ00571
0,7091
9 CDABCDEFGHIJ00572
1,4240
10 CDABCDEFGHIJ00573
0,0361
11 CDABCDEFGHIJ00574
0,5790
12 CDABCDEFGHIJ00575
0,4060
13 CDABCDEFGHIJ00576
0,3610
14 CDABCDEFGHIJ00577
0,6859
15 CDABCDEFGHIJ00578
0,2888
16 CDABCDEFGHIJ00579
0,0000
17 CDABCDEFGHIJ00580
0,0000
18 CDABCDEFGHIJ00581
0,0000
19 CDABCDEFGHIJ00582
0,0000
20 CDABCDEFGHIJ00583
0,0000
21 CDABCDEFGHIJ00584
0,0000
22 CDABCDEFGHIJ00585
0,8978
23 CDABCDEFGHIJ00586
0,0000
24 CDABCDEFGHIJ00587
2,3882
25 CDABCDEFGHIJ00588
0,0000
26 CDABCDEFGHIJ00589
2,0216
27 CDABCDEFGHIJ00590
1,7540
28 CDABCDEFGHIJ00591
0,0000
29 CDABCDEFGHIJ00592
0,0722
30 CDABCDEFGHIJ00593
0,0361
31 CDABCDEFGHIJ00594
0,0000
32 CDABCDEFGHIJ00595
0,0000
Total NAT files
11,9269
Direct inquiries to:
]]
by executing the code below
local ptrn = '\n([%d%p]+)\n'
for val1, val2 in string.gmatch(Amount, ptrn) do
print ("val1:=\t" .. (val1 or '').."\tval2:=\t"..(val2 or ''))
end
basically from the above string I want to fetch the last 5 digits of the string which is 00564 in val1 and the amount which is 0,1234 in val2 variable, but all this should in one pattern. This is a record, every record is starting with a number like this is 1 record or row
1 CDABCDEFGHIJ00564
0,1234
and this is 2nd record or row and so on
2 CDABCDEFGHIJ00565
0,0361
plese help....
It seems to me that %d+%s+%a+(%d+)\n%s*([%d,]+) should do the trick: the first %d+ will catch the row number, %s+ to match the white space after. %a+(%d+) will match CDABCDEFGHIJ00592 and capture the digits in the end (no way to specify that you want exactly five digits though). \n%s* will match the newline and any white space on the next line and ([%d,]+) will capture the last number with the comma.