Running sum current and previous row
Hi All, i want the result as showed in Final output column , can we achieve using anylatical function, plz provide me the solution only using SQL_
**Val YEAR MONTH MONTH_NO Final Out put**_
22 2001 OCT 10 22
24 2001 NOV 11 46
400 2001 DEC 12 446
405 2002 JAN 1 851
678 2002 FEB 2 1529
567 2002 MAR 3 2096
676 2002 APR 4 2772
67 2002 MAY 5 2839
76 2002 JUN 6 2915
Try something like this:
SELECT val
, yr
, mnth
, mnth_no
, SUM(val) OVER (ORDER BY TO_DATE(yr||mnth, 'YYYYMON')) AS final_output
FROM table_x
;Note that year and month are reserved words so they aren't good column names.
Similar Messages
-
Difference between current row and previous row in a table
Hi All,
I am having a problem with the query. Can some of please help me?
I need to get difference between current row and previous row in a table. I have a table, which have data like bellow.
TABLEX
================
Name Date Items
AAA 01-SEP-09 100
BBB 02-SEP-09 101
CCC 03-SEP-09 200
DDD 04-SEP-09 200
EEE 05-SEP-09 400
Now I need to get output like bellow...
Name Date Items Diff-Items
AAA 01-SEP-09 100 0
BBB 02-SEP-09 101 1
CCC 03-SEP-09 200 99
DDD 04-SEP-09 200 0
EEE 05-SEP-09 400 200
Can some one help me to write a query to get above results?
Please let me know if you need more information.
Thanks a lot in advance.
We are using Oracle10G(10.2.0.1.0).
Thanks
Asif, nvl (items - lag (items) over (order by dt), 0)like in
SQL> with test as
2 (
3 select 'AAA' name, to_date('01-SEP-09', 'dd-MON-rr') dt, 100 items from dual union all
4 select 'BBB' name, to_date('02-SEP-09', 'dd-MON-rr') dt, 101 items from dual union all
5 select 'CCC' name, to_date('03-SEP-09', 'dd-MON-rr') dt, 200 items from dual union all
6 select 'DDD' name, to_date('04-SEP-09', 'dd-MON-rr') dt, 200 items from dual union all
7 select 'EEE' name, to_date('05-SEP-09', 'dd-MON-rr') dt, 400 items from dual
8 )
9 select name
10 , dt
11 , items
12 , nvl (items - lag (items) over (order by dt), 0)
13 from test
14 ;
NAM DT ITEMS NVL(ITEMS-LAG(ITEMS)OVER(ORDERBYDT),0)
AAA 01-SEP-09 100 0
BBB 02-SEP-09 101 1
CCC 03-SEP-09 200 99
DDD 04-SEP-09 200 0
EEE 05-SEP-09 400 200
SQL> -
Report that display 'Net Pay' by Empl for current and previous period.
Hi,
We are looking for a SAP report that display 'Net Pay' by Employee for current and previous period in USA payroll module. If you know of any, pl let me know.
Thanks in advance,
NiranjanThanks Archana and Sikindar.
We knew about this report, however, it gives information one below the other if we run, say for 2 periods, but what we are looking for is something as shown in example below
Empl # Empl # Name Prev Pay period Net Pay Current Pay period net pay.
123 XYZ $ 1200.00 $ 1200.00
256 ABC $ 2000.00 $ 3000.00
We want to run for 2 periods at a time and get the results as above. That way, payroll dept can run this report and compare if we are paying too much in current pay, compared to previous pay. This is basically to avoid any typos when they create new pay records in infotype 0008.
Niranjan -
Selective deletion in DSO for current and previous year
Hi,
Can any one give an idea how can I selectively delete current and previous year data (only). is there any process type that can help me in process chains. This should be before loading a fresh load for the same period. this is for psodo delta.
or
any other alternative, plz. suggest.
Thanks
ganesh
Edited by: Ganesh on Jul 7, 2008 12:08 PMHi,
If you have any date value example posting date or 0CALMONTH.., you can filter the date using the selection conditions and selectively delete the data.
Process:
Manage of DSO->Contents Tab->Selective (with delete Icon)->Deletion selections->give the period->Execute->Start->Yes->continue.
Hope this helps..........
Rgs,
I.R.K -
Days difference between current row and previous row
I was able to obtain the date in the previous row and put it in the current row as below,
EVALUATE('LAG(%1,1) OVER (ORDER BY %1)', "- Response Date".Date)
but, when I try to calculate the difference between the two dates as below, I got the error message..
TIMESTAMPDIFF(SQL_TSI_DAY, EVALUATE('LAG(%1,1) over (order by %1)',"- Response Date".Date),"- Response Date".Date)
Error message says;
_State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 30483, message: ORA-30483: window functions are not allowed here at OCI call OCIStmtExecute. [nQSError: 17010] SQL statement preparation failed. (HY000)_
Please help~ Thanks in advance, gurus~~~http://obieeone.com/2010/04/27/use-of-evaluate-function-for-analytics-function-oracle/
the link might provide you with some additional insight into the error.
Let me know if that was helpful
-bifacts
http://www.obinotes.com -
12 month but devided into current and previous year
hi guys
i have this requirement to disaply amount for current period and previous period for 12 month.
Current period is the period of user entered year and previous period is previous year
So if user enter feb 2007 u2026Then current year is feb, jan ,dec 2006
And previous period is Nov 2006 to March 2006
user is entering the value 0CALMONTH ...and report to need to display 12 month internval betwen years. my problem is how to check the year and interval
please help me without any custom exit? can it be possible thru varibale?Hi,
I think i misunderstood your question previously.
You can create offsets on CALMONTH and achieve this easily.
1)In the columns are of query disigner, create selections for 12 months by using CALMONTH and offset each field by -1 or -2,-3,-4 ..... -12.
2) Create a Text Variable to show the month Value in column header
3) Create a structure in columns area and place it below all the CALMONTH selections
4) Include all your Key Figures inside the structure. -
Displaying current and previous 5 Year data in a bar graph
Hi ,
My requirement goes like this .....
I have to show revenue (measure) data based on current year (period dimension) selection (from a dashboard prompt) and previous 5 year data's as well .
i.e. if user selects 2013 , the bar graph will display 6 bars ... 2013,2012,2011,2010,2009,2008.
I am trying to achive this with filter on Year column , on the main report ....*"is based on results of another analysis"*
But haven't made any progress .
Thanks
sayaksayak wrote:
Hi ,
My requirement goes like this .....
I have to show revenue (measure) data based on current year (period dimension) selection (from a dashboard prompt) and previous 5 year data's as well .
i.e. if user selects 2013 , the bar graph will display 6 bars ... 2013,2012,2011,2010,2009,2008.
I am trying to achive this with filter on Year column , on the main report ....*"is based on results of another analysis"*
But haven't made any progress .
Thanks
sayakFollow this link. It will give you greater flexibility for you end users and therefore a better report.
http://oraclebizint.wordpress.com/2008/03/11/oracle-bi-ee-101332-rolling-yearmonth-and-date-filters-moving-window-filters/ -
Hello everybody,
I am SAP XI Architect. I am analyzing an interface for customer balances. I have a requirement to send the Current balance and Previous balance to 3rd party tool. The previous balance is till last transaction period (for example: till last quarter or till last month). In which Transaction I can find this balances?
With my little FI knowledge I tried these T-codes FD10N, FS10N, F.08... Can I find my requirement in this T-codes?
Thanks in Adv,
Greetings
XI/PIHi, KE24 gives the details, if you just want to know the details. You need to give the operating concern. Record type F (billing), company code and the period for which you want to know the balance.
You need to change the layout for sales order and Product. Hope this helps. -
IPod shuffle current and previous gen
I was going through the Apple Store's refurb iPod site and saw that the current generation iPod shuffle and previous generation iPod shuffle look exactly alike. They're of the clip type. Now, what has actually improved in the current generation of the iPod shuffle?
Frank F. wrote:
The latest iPod shuffle was never claimed to be of a new generation at all - it still belongs to the second generation. However, there have been a number of minor revisions within this generation:
a) Original: Silver only, 1 GB, old headphones
b) Neon color models added, new headphones
AppleStore refurbs page calls this the "previous generation"
c) Neon colors replaced by pastel colors
AppleStore refurbs page calls this the "current generation"
d) 2 GB model added, price cut
Price was cut before 2GB was actually available, although announced
simultaneously with price cut... -
Each time I boot my Macbook Pro running a currently patched version of Yosemite I am asked to "Sign in with my Apple ID." After that I have to approve the use of Find My Mac, and then I have to agree to the Terms and conditions of Use. This is very annoying since I use Bootcamp a lot and it adds a fair effort to the reboot process. Any thoughts?
Some additional clues that may or may not have bearing on this.
Once I am booted into Yosemite completely, if I open Safari (also current version) I am told my Safari Extensions have been migrated and I have to re-enable each one individually. They have all been disabled. This will occur each time I completely close Safari and reopen it.
I appreciate your thoughts and suggestions everyone! Thanks in advance.
DaveHi chc517,
I'm sorry to hear you are having issues with your MacBook Pro. I also apologize, I'm a bit unclear on a couple things about your specific configuration. The message you mentioned about the disk being encrypted would seem to indicate that you may have File Vault enabled. If that is the case and you are having a login issue, you would need to use the File Vault recovery key to reset your login password instead of your Apple ID, as noted in the following article:
OS X Yosemite: FileVault recovery key
Regards,
- Brenden -
A better way to get current and previous status?
I'm working on a system where status messages are read into a table for items of equipment. My requirement is to find all the messages arriving within a particular time window, together with the status value and the status value for the previous message sent for that equipment item, if any. This previous message can (and probably will) have a date outside the window I'm looking at, or might not exist at all for a brand new equipment item.
The table looks something like this:
create table eq_state
(eq_id NUMBER, -- ID of the equipment
event_date DATE, -- Date/Time of the message
status NUMBER) -- Status passed in the messageThere are indexes on (event_date,eq_id) and on eq_id. It'll get very big, so it's important that indexes are used wherever possible.
Here's what I have so far:
WITH eq_state AS
SELECT 1 eq_id, TO_DATE('01/05/2013 12:01:00','DD/MM/YYYY HH:MI:SS') event_date, 1 status FROM DUAL
UNION ALL
SELECT 2 eq_id, TO_DATE('01/05/2013 01:01:00','DD/MM/YYYY HH:MI:SS') event_date, 2 status FROM DUAL
UNION ALL
SELECT 2 eq_id, TO_DATE('01/05/2013 12:02:00','DD/MM/YYYY HH:MI:SS') event_date, 3 status FROM DUAL
UNION ALL
SELECT 3 eq_id, TO_DATE('01/05/2013 10:00:00','DD/MM/YYYY HH:MI:SS') event_date, 4 status FROM DUAL
UNION ALL
SELECT 3 eq_id, TO_DATE('01/05/2013 12:03:00','DD/MM/YYYY HH:MI:SS') event_date, 5 status FROM DUAL
UNION ALL
SELECT 3 eq_id, TO_DATE('01/05/2013 12:04:00','DD/MM/YYYY HH:MI:SS') event_date, 6 status FROM DUAL
SELECT eq_id,TO_CHAR(event_date,'DD/MM/YYYY HH:MI:SS') event_date,curr_state,prev_state
FROM (SELECT Es.Eq_Id,
Es.Event_Date,
Es.Status AS Curr_State,
Es2.Status AS Prev_State,
RANK() OVER (PARTITION BY es.eq_id,es.event_date ORDER BY es2.event_date DESC) the_rank
FROM Eq_State Es
LEFT OUTER JOIN Eq_State Es2
ON Es2.Eq_Id = Es.Eq_Id
AND Es2.Event_Date < Es.Event_Date
WHERE Es.Event_Date BETWEEN TO_DATE('01/05/2013 12:00:00','DD/MM/YYYY HH:MI:SS')
AND TO_DATE('01/05/2013 12:05:00','DD/MM/YYYY HH:MI:SS')) x
WHERE the_rank = 1
ORDER BY 1,2This gives me the desired results and seems to use sensible indexes (I'll spare you the explain plan):
EQ_ID EVENT_DATE CURR_STATE PREV_STATE
1 01/05/2013 12:01:00 1
2 01/05/2013 12:02:00 3 2
3 01/05/2013 12:03:00 5 4
3 01/05/2013 12:04:00 6 5So what's the problem? Just curiosity really - the technique of finding the RANK() in the inline view, and then selecting rows where it's equal to 1 seems like a bit of a kludge. Is there a more elegant way to do it? Maybe something using LAG() or KEEP DENSE_RANK LAST?
I'm still not really up-to-speed with analytic functions, so I'm hoping to learn something from those of you that are!
ORACLE 11.2.0.1.0 by the wayI would use another way, firstly sorting by any unique criteria and using joins
WITH eq_state AS
SELECT 1 eq_id, TO_DATE('01/05/2013 12:01:00','DD/MM/YYYY HH:MI:SS') event_date, 1 status FROM DUAL
UNION ALL
SELECT 2 eq_id, TO_DATE('01/05/2013 01:01:00','DD/MM/YYYY HH:MI:SS') event_date, 2 status FROM DUAL
UNION ALL
SELECT 2 eq_id, TO_DATE('01/05/2013 12:02:00','DD/MM/YYYY HH:MI:SS') event_date, 3 status FROM DUAL
UNION ALL
SELECT 3 eq_id, TO_DATE('01/05/2013 10:00:00','DD/MM/YYYY HH:MI:SS') event_date, 4 status FROM DUAL
UNION ALL
SELECT 3 eq_id, TO_DATE('01/05/2013 12:03:00','DD/MM/YYYY HH:MI:SS') event_date, 5 status FROM DUAL
UNION ALL
SELECT 3 eq_id, TO_DATE('01/05/2013 12:04:00','DD/MM/YYYY HH:MI:SS') event_date, 6 status FROM DUAL
), sorted as (
select row_number() over (order by a.event_date) as rn, a.* from eq_state a
select * from sorted s1
left join sorted s2 on (s2.rn = s1.rn -1)
order by s1.rn
RN EQ_ID EVENT_DATE STATUS RN EQ_ID EVENT_DATE STATUS
1 2 01.05.2013 01:01:00 2
2 3 01.05.2013 10:00:00 4 1 2 01.05.2013 01:01:00 2
3 1 01.05.2013 12:01:00 1 2 3 01.05.2013 10:00:00 4
4 2 01.05.2013 12:02:00 3 3 1 01.05.2013 12:01:00 1
5 3 01.05.2013 12:03:00 5 4 2 01.05.2013 12:02:00 3
6 3 01.05.2013 12:04:00 6 5 3 01.05.2013 12:03:00 5 -
Creating View based on Current and previous data from same table
I am trying to create a view based on a table called “my_companies”. The table has following columns: “company_id”, “start_date”, “product_type_code”, “partner_id”
The main purpose of this view is to obtain previous company_id’s associated with a particular “partner_id“and “product_type_code”. So basically, I’m looking to create an extra column, say “prev_company_id” in the view along with all the other columns. The “previous” data can be obtained depending on the “start_date”. I’m not able to write a query successfully to do this.
Can anyone help? Thanks in advance.Hi,
Whenver you have a question, it helps to post:
(1) The version of Oracle (and any other relevant software) you're using
(2) A little sample data (just enough to show what the problem is) from all the relevant tables
(3) The results you want from that data
(4) Your best attempt so far
Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
Formatted tabular output is okay for (3). Type before and after the tabular text, to preserve spacing. The sample results should include any special cases that you foresee, such as one company having many previous companies, or vice-versa.
It sounds like might need a +self-join+, where you have two copies of the same table, as if the current companies were in one table and the previous companies were in another, even though they are all actually in the same table. -
Where to compare Current and previous messages.
i had requirment where i had to insert the text data from FTP to MSSQL Database
(R/3) File -> Xi -> JDBC.
but the condition is -> In case the SQL server is down for any time (1 Jan to 4 Jan), and when SQL Server is UP on 5 jan, All the data in R/3 form 1-4 Jan shall also be udpated on 5th Jan.
Check has to be made by XI whether Current Data DATE is 1 more then previous data DATE.
(i.e on 5 day XI has to check whether 4 Jan Data has passed Xi Sucessfuly or not)
My Views : Alert can be used to identify the days of downtime, and we again put the file from Archives to FTP.
But this process also has to be automated, no manual intervention on taking file from archives
I had to use BPM.?
any Inputs..?
Regards
Ajay PantHI,
In both the cases u require to write a java code in UDF and pass the value to either DB or R3.
Here are few links which will help u..
Lookup - /people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
DB lookup - /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
SOAP Lookup - /people/bhavesh.kantilal/blog/2006/11/20/webservice-calls-from-a-user-defined-function
http://help.sap.com/saphelp_nw04/helpdata/en/cf/406642ea59c753e10000000a1550b0
Lookups in XI made simpler - /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
How to check JDBC SQL Query Syntax and verify the query results inside a User Defined Function of the Lookup API -
http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
/people/prasad.illapani/blog/2006/10/25/how-to-check-jdbc-sql-query-syntax-and-verify-the-query-results-inside-a-user-defined-function-of-the-lookup-api
Lookups - /people/morten.wittrock/blog/2006/03/30/wrapping-your-mapping-lookup-api-code-in-easy-to-use-java-classes
Lookups - /people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler
http://help.sap.com/saphelp_nw04/helpdata/en/cf/406642ea59c753e10000000a1550b0/content.htm
/people/sap.user72/blog/2005/12/06/optimizing-lookups-in-xi
Lookups with XSLT - https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8e7daa90-0201-0010-9499-cd347ffbbf72
/people/sravya.talanki2/blog
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/05a3d62e-0a01-0010-14bc-adc8efd4ee14
Thnx
Chirag -
Display current and previous months records only
Hello gang,
My selection criteria looks like this:
not ({HRDEPBEN.PLAN_CODE} startswith ["C", "EAP", "HMIL", "V", "W"]) and
(month({hrdepben.Creation_date}) = month(currentdate)) and
{HRDEPBEN.PLAN_TYPE} = "HL"
I modified it to this in order to pull in previous month's data too:
{HRDEPBEN.PLAN_TYPE} = "HL" and
not ({HRDEPBEN.PLAN_CODE} startswith ["C", "EAP", "HMIL", "V", "W"]) and
(month({hrdepben.Creation_date}) = month(currentdate) or month ({hrdepben.Creation_Date})= month (currentdate)-1)
However, it's still pulls the same record count and only January records, not Decembers'.
Where am I going wrong?
ThanksLooks like you're reporting against Lawson? What database are you using?
There are a few issues with the record selection criteria as it's written:
1) Month(CurrentMonth) - 1 = 0 when the current month is January. That's why your not getting any records from December.
2) The monthly criteria won't be passed to the database for processing, which is a huge performance issue when you're reporting against a system like Lawson. You're basically telling the report to bring back all records that don't start with an array of values, irrespective of the date. Only after all the possible records are returned across the network will the extraneous records be filtered out on the client side. That's bad.
3) It's easy to use StartsWith or Like, but it's also pretty inefficient, since it forces a full table scan of the underlying table
Personally, I'd do one of two things in order to both fix the query and optimize it:
1) Write the underlying query in SQL as either a View or SQL Command object
or
2) Keep the current report, but make use of SQL Expression fields in order to optimize the query.
Here are some examples of SQL Expression fields against Oracle (PL/SQL) that could be useful:
/*{%PLANCODES}*/
/*This SQL Expression evaluates whether or not a Plan Code starts with the specified values*/
/*"HRDEPBEN"."PLAN_CODE" is selected directly from the Field Tree in the SQL Expression Editor*/
CASE
WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",1) IN ('C','V','W') THEN 'Y'
WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",3) = 'EAP' THEN 'Y'
WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",4) = 'HMIL' THEN 'Y'
ELSE 'N'
END
/*{&CREATEDATEMONTH}*/
/*This SQL Expression returns the month of the Creation Date field*/
/*"HRDEPBEN"."CREATION_DATE" is selected directly from the Field Tree in the SQL Expression Editor*/
TO_NUMBER(TO_CHAR("HRDEPBEN"."CREATION_DATE",'mm'))
You could also create formula to return the Month value for last month and then use it in your record selection:
//{@LASTMONTH}
//This formula returns the Month value for Last Month
//IIF statements can be passed to the database for processing
IIF(Month(CurrentDate) = 1, 12, Month(CurrentDate) - 1)
With expressions and formulas like these in place (this code is Oracle and DB2 compatible, it would be different for T-SQL), you could then modify your record selection criteria to be something simpler, like this:
{HRDEPBEN.PLAN_TYPE} = "HL" and
{%PLANCODES} = 'N' and
{%CREATEDATEMONTH} IN {@LASTMONTH} TO MONTH(CURRENTDATE)// MONTH(CURRENTDATE) is passed to the DB
By laying the groundwork, you'll have a much more efficient report and, in the case of the @LastMonth, more accurate! Hope this helps!
p.s. a disclaimer on using SQL Expressions in this manner - it's not officially supported, although it's worked since Version 7 (when SQL Expressions were introduced) and there will be support for them in various 2011 versions. As such, they'll work for years. I use them all the time and they're fantastic for optimizing reports. -
Adding rows based on current and next row
I got some excellent help on multiplying rows based on start and end date in this
thread, resulting in the query below. It helps me follow Vehicle activity and Vehicle allocation of our vehicles day by day. Now I would like to add another feature to the query, if it is possible.
The problem is that in our database, only actual tasks are registered, which means that the time when the vehicle is between tasks is not showing. I could of course calculate total available time per vehicle and month, but that would not tell me where the
vehicles are waiting, when during the day, etc.
So I would like to insert rows for when the vehicles are standing still, and the logic would be something like this:
If vehicle number on current row equals vehicle number on the next row and End (date/time) of current row < Start (date/time) of next row, insert row after current row. Set Start=End of current row and End=Start of next row. Set From=To
of current row and To=To of current row. Set Vehicle activity to "Not active". Finaly copy all other fields from current row.
Is this possible to achieve in Power Query?
Brgds,
Caj
let
Source = Sql.Databases("sql10"),
SLM = Source{[Name="SLM"]}[Data],
dbo_V_LKPI = SLM{[Schema="dbo",Item="V_LKPI"]}[Data],
RenamedColumns = Table.RenameColumns(dbo_V_LKPI,{{"ActualDeparture", "Start"}, {"ActualArrival", "End"}}),
Records = Table.ToRecords(V_LocoKPI),
DateTime.IsSameDay = (x, y) => Date.Year(x) = Date.Year(y) and Date.Month(x) = Date.Month(y) and Date.Day(x) = Date.Day(y),
Expand = (x) => List.Generate(
() => Record.Combine({x, [End=Date.EndOfDay(x[Start])]}),
(record) => record[Start] <= x[End],
(record) => let
NextStart = Date.StartOfDay(Date.AddDays(record[Start], 1)),
NextEnd = Date.EndOfDay(NextStart),
ThisEnd = List.Min({NextEnd, x[End]})
in
Record.Combine({record, [Start=NextStart, End=ThisEnd]})),
Transformed = List.Transform(Records, each if DateTime.IsSameDay([Start], [End]) then {_} else Expand(_)),
Combined = List.Combine(Transformed),
Result = Table.FromRecords(Combined)
in
Result
CstenHere's some sample code. Again, we use List.Generate to build either a record or a list of records and then use List.Combine to bring the results back together before converting them to a table.
let
CombineTwoRows = (x, y) =>
let
combine = x[Vehicle] = y[Vehicle] and x[End] < y[Start],
added = Record.Combine({x, [Start=x[End], End=y[Start], Active=false]}),
result = if combine then {added, y} else {y}
in result,
GenerateStandingRows = (table, combine) =>
let
Handle = (x, y) => {x, y},
buffered = Table.Buffer(table),
n = Table.RowCount(buffered),
windows = List.Generate(
() => {1, {buffered{0}}},
(x) => x{0} <= n,
(x) => {x{0} + 1, if x{0} < n then combine(buffered{x{0}-1}, buffered{x{0}}) else {buffered{x{0}}}},
(x) => x{1})
in
windows,
InsertInactivity = (table) => Table.FromRecords(List.Combine(GenerateStandingRows(table, CombineTwoRows))),
TestData = Table.FromRows({
{1, #datetime(2014, 2, 23, 13, 0, 0), #datetime(2014, 2, 23, 13, 10, 0), true},
{1, #datetime(2014, 2, 23, 13, 20, 0), #datetime(2014, 2, 23, 13, 30, 0), true},
{2, #datetime(2014, 2, 23, 13, 20, 0), #datetime(2014, 2, 23, 14, 0, 0), true},
{2, #datetime(2014, 2, 23, 14, 20, 0), #datetime(2014, 2, 23, 14, 40, 0), true},
{2, #datetime(2014, 2, 23, 16, 0, 0), #datetime(2014, 2, 23, 17, 0, 0), true},
{2, #datetime(2014, 2, 24, 2, 0, 0), #datetime(2014, 2, 24, 3, 0, 0), true},
{3, #datetime(2014, 2, 24, 1, 0, 0), #datetime(2014, 2, 24, 8, 0, 0), true},
{3, #datetime(2014, 2, 24, 9, 0, 0), #datetime(2014, 2, 24, 10, 0, 0), true}
}, {"Vehicle", "Start", "End", "Active"})
in
InsertInactivity(TestData)
Maybe you are looking for
-
How to bold part of text in javascript
Hi, I have a form which puts several text fields in to one text box. I have a link at the bottom as an example. It was based on an example I found on: http://www.assuredynamics.com/index.php/portfolio/concatenating-and-floating-fields/ Basically Im n
-
The symptom is that I connect successfully to my POP3 inbound server but no mail appears in my Inbox. Sending mail is fine - the messages get out and are recorded correctly in the Sent Messages.mbox Given the following: 1) Connection Doctor shows
-
Is there a Quick way to exactly center Illustrator artboard in work area?
Good Day, Illustrator Mavens: Many files I receive from clients have their art boards set up way off center within the work area. This would most times not be a problem, but many times I need to scale up their files for more precision for output purp
-
HT1918 link apple id to a new email address
Hi, I am using my company email address as apple ID and now that i am leaving them, they need to cease my email account. How can i change to a new (personal) email address and retain everything on this current account? Appreciate all your help guys!
-
How can I configure my T430 to wake from sleep by using 'fingerprint' instead of a 'password'?