Counting consecutive events
Hello, I try to count how often a true/false indicator is true. I'm using a "(U16) count: the number of TTL rising edges counted" after it, but with every incoming value the counter sets to 0. Therefore I always have 0 or 1 on the front panel instead of adding the new true to the previous ones. Thanks
Sounds like your counter might be in a While Loop using an initialized shift register, probably in a sub-vi. If you have a 0 connected to the left side register outside the loop, everytime the loop runs, it will reset the register to 0.
There are ways to initialize shift registers inside the loop if needed so this problem won't happen.
If this is not the problem, post some more details, or attach the code to another message so we can have a look.
Ed
Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Similar Messages
-
Count digital events on a Counter with pci-6602 with callback on CVI
Hi,
I'm using a PCI-6602 card with CVI 8.5 and I need to trig on event.
On every pulse I received, I need to do some actions like increasing a counter, send a message on Rs232 etc.. I don't want to do any loop checking that the counter value has changed. I would like to use a callback to execute this code only on the edge or counter value event.
My problem is that I don't know which function can do this. Is there any way to get an event on a pci-6602?
Thanks
James
Solved!
Go to Solution.Hello.
It's completely possible to create a callback that will allow you to do what you want when a edge will occur on an external signal you define.
To do this, you can for exemple create a counting edges task that will use one of the 6602 counters,and the set your external signal to be the source of your sample clock.You'll then be able to register a callback with the function DAQmxRegisterSignalEvent, and your callback will be called each time an edge will occur on your specified sample clock source.
Here's 2 links that explain the events in DAQmx and how to handle them in CVI. The example ReadDigChan-ChangeDetectionEvent.pr that ships with DAQmx examples (Hardware Input and Output<<DAQmx<<Digital measurements) can be very useful to understand how to do. This example creates a signal event callback to detect change detection for digital inputs.
Regards. -
Count consecutive days in array
Hi,
I'm looking for an algorithm to count consecutive days in array, but i don't find one.
for example, if i have this array.
2009/07/01
2009/07/02
2009/07/03
2009/07/06
2009/07/08
2009/07/09
2009/07/10
2009/07/11
The result be
3
1
4
Anyone have one?
Thanks for all.jverd wrote:
kajbj wrote:
It's a fairly specialist algorithm so you are unlikely to find someone to post a solution. By just keeping a reference to the previous date, it is easy to iterate though the list counting consecutive dates.I think the trick to making this algorithm sucessful is to make sure that when you change months your algorithm doesn't set consec_days to 0 Why not?Presumably he's talking about this case:
7/31
8/1
and not this case
7/1
8/1
So he really should have said, "...when you increment month by one, or from 12 to 1, and the day went from the last day of the old month to 1, don't set consec_days to 0"Ok. I would use the Calendar class and SimpleDateFormat. The tricky part would otherwise be to keep track of days per month, and leap year. -
Hi,
I had a requirement like this
<pre>
In Table View output is like this
ID STATUS DATE
101 01 03-01-11
101 02 09-02-11
101 03 11-03-11
101 02 06-04-11
101 02 07-05-11
101 03 09-06-11
101 02 14-07-11
101 02 15-08-11
101 04 12-09-11
101 03 10-10-11
101 03 12-11-11
101 03 08-12-11
</pre>
<pre>
Required Output should be like this - for ID 101 and STATUS '01' is not required
STATUS 1Time 2Time 3&4Time 5&above
02 1 2
03 2 1
04 1
</pre>
Columns 1Time, 2Time,3&4Time, 5&above means count the number of consecutive appeareance of the status (have to check previous month status and next month status)
i.e for example if we take Status '02'
after checking previous month and next month status, Status '02' has appeared one time consecutively on '01-02-11'(Feb)
and hence 1 should come under '1Time' Column.
similarly after checking previous month and next month status, the number of 2 consecutive appereance of status '02' is twice, that is on ('01-04-11', '01-05-11') and ('01-07-11', '01-08-11'),hence the count of them will 2 under '2Time' column
For Status '03',
there are two one-time consecutive appeareance of the Status, that is on '01-03-11' and '01-06-11'. Hence count is 2 under '1Time' column for status 03
and Status '03' has single 3 consecutive appearance, that is on '01-10-11', '01-11-11', '01-12-11', hence count is 1 under 3&4Time coulmn.
Regards
mohanI did answer your question in the other forum:
Count consecutive appearance
hm -
SCOM-Difference between Problem Count and Event Count in Application Failure Analysis Report
Dear All,
Could someone explain me clearly , the difference between Problem Count and
Event Count in Application Failure Analysis Report. Please help me in understanding What is meant be problem and event in the report .
Thanks in Advance.
Regards,
Rajesh Kumar CHello Rajesh,
The "problem" is the logically grouped set of the exception events which have the identical hash calculated over several fields as "Stack", "Source", "Failed Function" and so on... So, even if exceptions are different
in the other properties but hash matches over the considered properties - then all those exceptions go into the same "problem group".
So, event is an instance of the problem. One event contributes to one problem but one problem might have a huge event count if you have a repeating issue.
The logic is similar for the performance analysis report, only fields that go into the "problem" hash are different. e.g. "Stack" is not used in hash for perf events...
Dmitry Matveev -
Counting consecutive numbers into one row
Hello everyone,
I have recently discovered that we can use Max ( Decode ()) function of Oracle to pivot the results of a table. I have executed this just fine. However, pivoting a table is just one part of the solution that I need. The pivoting function results to something like this:
01,02,03,05,06,07,08,09,10,11,12,13,14,16,17,20,21,23,25What I actually need is something like this:
1-17, 20-21,23,25I really don't know how to start solving this but so far I have the below query:
SELECT DISTINCT
MAX(DECODE(wldw.wafernumber,'01', '01'))
|| MAX(DECODE(wldw.wafernumber,'02', ',02'))
|| MAX(DECODE(wldw.wafernumber,'03', ',03'))
|| MAX(DECODE(wldw.wafernumber,'04', ',04'))
|| MAX(DECODE(wldw.wafernumber,'05', ',05'))
|| MAX(DECODE(wldw.wafernumber,'06', ',06'))
|| MAX(DECODE(wldw.wafernumber,'07', ',07'))
|| MAX(DECODE(wldw.wafernumber,'08', ',08'))
|| MAX(DECODE(wldw.wafernumber,'09', ',09'))
|| MAX(DECODE(wldw.wafernumber,'10', ',10'))
|| MAX(DECODE(wldw.wafernumber,'11', ',11'))
|| MAX(DECODE(wldw.wafernumber,'12', ',12'))
|| MAX(DECODE(wldw.wafernumber,'13', ',13'))
|| MAX(DECODE(wldw.wafernumber,'14', ',14'))
|| MAX(DECODE(wldw.wafernumber,'15', ',15'))
|| MAX(DECODE(wldw.wafernumber,'16', ',16'))
|| MAX(DECODE(wldw.wafernumber,'17', ',17'))
|| MAX(DECODE(wldw.wafernumber,'18', ',18'))
|| MAX(DECODE(wldw.wafernumber,'19', ',19'))
|| MAX(DECODE(wldw.wafernumber,'20', ',20'))
|| MAX(DECODE(wldw.wafernumber,'21', ',21'))
|| MAX(DECODE(wldw.wafernumber,'22', ',22'))
|| MAX(DECODE(wldw.wafernumber,'23', ',23'))
|| MAX(DECODE(wldw.wafernumber,'24', ',24'))
|| MAX(DECODE(wldw.wafernumber,'25', ',25')) AS WAFERS
FROM a_wiplothistory wl
JOIN Container C ON (wl.containerid = c.containerid OR wl.containerid= c.splitfromid )
JOIN a_wiplotdetailshistory wld ON wl.wiplothistoryid = wld.wiplothistoryid
JOIN a_wiplotdetailswafershistory wldw ON wld.wiplotdetailshistoryid = wldw.wiplotdetailshistoryid
WHERE c.containername = :lotThanks for helping guys.
Edited by: 1001275 on May 15, 2013 6:28 PMHi,
1001275 wrote:
Hello everyone,
I have recently discovered that we can use Max ( Decode ()) function of Oracle to pivot the results of a table. I have executed this just fine. However, pivoting a table is just one part of the solution that I need...You said it!
First, you need some way of grouping consecutive rows together (1-17 in one group, 20-21 in anoter, 23 as a group all by itself, and so on).
Then you need GROUP BY to get infmation about each goup, such as the smallest and largest number in the group.
Finally, you need to combine all that information into one big string. This is actually an example of String Aggregation , rather than pivoting. The two are closely related. Pivot means you're taking 1 column on multiple rows, and putting them into multiple columns on one row. String Aggregation is taking 1 column on multple row, and concatenating all their contents into one big string column.
Here's one way to do it:
WITH got_group_id AS
SELECT wafernumber
, ROW_NUMBER () OVER (ORDER BY wafernumber)
- wafernumber AS group_id
FROM wldw
, got_group_info AS
SELECT TO_CHAR (MIN (wafernumber))
|| CASE
WHEN COUNT (*) > 1
THEN '-' || TO_CHAR (MAX (wafernumber))
END AS group_label
, ROW_NUMBER () OVER (ORDER BY MIN (wafernumber))
AS group_num
FROM got_group_id
GROUP BY group_id
SELECT SUBSTR ( SYS_CONNECT_BY_PATH (group_label, ',')
, 2
) AS txt
FROM got_group_info
WHERE CONNECT_BY_ISLEAF = 1
START WITH group_num = 1
CONNECT BY group_num = PRIOR group_num + 1
AND prior sys_guid () is not null
;I find the first part of this query to be the trickiest. I used the Fixd Difference technique to assign a common group_id to consecutive rows. See {message:id=9953384} and/or {message:id=9957164} foran explantaion of the Fixed Difference technique.
Next, in sub-query got_group_info, I used aggregate functions to produce a group_label, such as '1-17', and to assign consecutive numbers to each group. This is also a little tricy, because it involves nesting an aggregate function (MIN in this case) inside an analytc function (ROW_NUMBER).
Finally, I used SYS_CONNECT_BY_PATH to do the string aggregation.
Output:
TXT
1-17,20-21,23,25Whenever you have a question, please post CREATE TABLE and INSERT statements for some sample data. For example:
CREATE TABLE wldw
( wafernumber NUMBER (3) PRIMARY KEY
INSERT INTO wldw (wafernumber) VALUES ( 1);
INSERT INTO wldw (wafernumber) VALUES ( 2);
INSERT INTO wldw (wafernumber) VALUES ( 3);
INSERT INTO wldw (wafernumber) VALUES ( 4);
INSERT INTO wldw (wafernumber) VALUES ( 5);
INSERT INTO wldw (wafernumber) VALUES ( 6);
INSERT INTO wldw (wafernumber) VALUES ( 7);
INSERT INTO wldw (wafernumber) VALUES ( 8);
INSERT INTO wldw (wafernumber) VALUES ( 9);
INSERT INTO wldw (wafernumber) VALUES (10);
INSERT INTO wldw (wafernumber) VALUES (11);
INSERT INTO wldw (wafernumber) VALUES (12);
INSERT INTO wldw (wafernumber) VALUES (13);
INSERT INTO wldw (wafernumber) VALUES (14);
INSERT INTO wldw (wafernumber) VALUES (15);
INSERT INTO wldw (wafernumber) VALUES (16);
INSERT INTO wldw (wafernumber) VALUES (17);
INSERT INTO wldw (wafernumber) VALUES (20);
INSERT INTO wldw (wafernumber) VALUES (21);
INSERT INTO wldw (wafernumber) VALUES (23);
INSERT INTO wldw (wafernumber) VALUES (25);I realize that your table (and your query) are a lot more complicated, but it looks like you can show the part you don't already understand using just this one table with this one column.
Also, whenever you have a question, say which version oif Oracle you'e using (e.g., 11.2.0.2.0).
The query above should work in Oracle 10.1 and up. I got the wong results in the main query in Oracle 10.2, however. (Oracle 10.2 has a lot of bugs related to CONNECT BY.) It worked fine in version 11.1.
If you're using Oracle 11.2, you'll want to use LISTAGG, not SYS_CONNECT_BY_PATH, to do the string aggregation.
For more about string aggregation in various versions of Oracle, see this Oracle Base page. -
Custom Rule - Count of Event ID
I have a custom rule in SCOM 2012 for event ID 4648 in the security log. This will only alert when parameter 6 equals a specific user id. That works fine.
But, I want to get a count of how many times event id 4646 appears in the log for this user. How do I do that?
Thank you in advance.Adding more info:
How an Alert is Produced
http://technet.microsoft.com/en-us/library/hh212847.aspx
We
are trying to better understand customer views on social support experience, so your participation in this
interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place. -
Count consecutive Workdays where employee has taken SICK leave
I am trying to identify a way within sql to count the number of consecutive workdays (Monday - Friday) an employee has taken SICK leave. My problem in the past has been trying to count days whereas we cross the weekend. Currently I have 4 queries identifying patterns around the weekend that I run and export into an Excel Spreadsheet and manipulate from there. My goal is to be able to list an EMPLID (employee id), EMPL_RCD ( employee record), Min(DUR) (Date of absence), Max(DUR), and count of consecutive workdays.
Any help or guidance would will be appreciated. I have attached my current query.
I run my current query 4 times using the patterns below one at a time.
SELECT DISTINCT A.EMPLID,A.EMPL_RCD, A.DUR,b.dur,c.dur,d.dur, A.TL_QUANTITY, A.TRC
FROM PS_TL_RPTD_TIME A, PS_TL_RPTD_TIME B, PS_TL_RPTD_TIME C,PS_TL_RPTD_TIME D
WHERE A.EMPLID = B.EMPLID
AND A.EMPL_RCD = B.EMPL_RCD
AND A.EMPLID = C.EMPLID
AND A.EMPL_RCD = C.EMPL_RCD
AND A.EMPLID = D.EMPLID
AND A.EMPL_RCD = D.EMPL_RCD
AND B.EMPLID = C.EMPLID
AND B.EMPL_RCD = C.EMPL_RCD
AND B.TRC = C.TRC
AND A.TRC = B.TRC
AND A.TRC = C.TRC
AND A.TRC = D.TRC
AND (B.DUR = A.DUR+3 AND C.DUR = A.DUR+4 AND D.DUR = A.DUR+5) Friday, Monday, Tuesday, Wednesday
AND (B.DUR = A.DUR+1 AND C.DUR = A.DUR+4 AND D.DUR = A.DUR+5) Thursday, Friday, Monday, Tuesday
AND (B.DUR = A.DUR+1 AND C.DUR = A.DUR+2 AND D.DUR = A.DUR+5) Wednesday, Thursday, Friday, Monday
AND (B.DUR = A.DUR+1 AND C.DUR = A.DUR+2 AND D.DUR = A.DUR+3) -- Same workweek
AND A.TRC LIKE 'SICK%'
AND NOT EXISTS ( SELECT 'x' FROM PS_JOB J
WHERE J.EMPLID = A.EMPLID
AND J.EMPL_RCD = A.EMPL_RCD
AND J.EMPL_STATUS IN ('P','L')
AND J.EFFDT = ( SELECT MAX(J1.EFFDT) FROM PS_JOB J1
WHERE J1.EMPLID = J.EMPLID
AND J1.EMPL_RCD = J.EMPL_RCD
AND J1.EFFDT <= D.DUR))You should consider a technique from data warehousing where you use a table to describe dates. To keep things simple, let's create a table that holds all your valid business days for the past 2 weeks...
create table business_dates (business_day date);
begin
insert into business_dates values (to_date('16-oct-2006'));
insert into business_dates values (to_date('17-oct-2006'));
insert into business_dates values (to_date('18-oct-2006'));
insert into business_dates values (to_date('19-oct-2006'));
insert into business_dates values (to_date('20-oct-2006'));
insert into business_dates values (to_date('23-oct-2006'));
insert into business_dates values (to_date('24-oct-2006'));
insert into business_dates values (to_date('25-oct-2006'));
insert into business_dates values (to_date('26-oct-2006'));
insert into business_dates values (to_date('27-oct-2006'));
insert into business_dates values (to_date('30-oct-2006'));
insert into business_dates values (to_date('31-oct-2006'));
insert into business_dates values (to_date('01-nov-2006'));
insert into business_dates values (to_date('02-nov-2006'));
insert into business_dates values (to_date('03-nov-2006'));
end;
now we create a table that shows whether each employee was sick or not for a given work day...
create table attendance (empid number, business_day date, sick char(1));
insert into attendance values (100, to_date('16-oct-2006'), 'N');
insert into attendance values (100, to_date('17-oct-2006'), 'Y');
insert into attendance values (100, to_date('18-oct-2006'), 'Y');
insert into attendance values (100, to_date('19-oct-2006'), 'N');
insert into attendance values (100, to_date('20-oct-2006'), 'N');
insert into attendance values (100, to_date('23-oct-2006'), 'Y');
insert into attendance values (100, to_date('24-oct-2006'), 'Y');
insert into attendance values (100, to_date('25-oct-2006'), 'Y');
insert into attendance values (100, to_date('26-oct-2006'), 'N');
insert into attendance values (100, to_date('27-oct-2006'), 'N');
insert into attendance values (100, to_date('30-oct-2006'), 'N');
insert into attendance values (100, to_date('31-oct-2006'), 'Y');
insert into attendance values (100, to_date('01-nov-2006'), 'N');
insert into attendance values (100, to_date('02-nov-2006'), 'N');
insert into attendance values (100, to_date('03-nov-2006'), 'N');
insert into attendance values (105, to_date('16-oct-2006'), 'Y');
insert into attendance values (105, to_date('17-oct-2006'), 'Y');
insert into attendance values (105, to_date('18-oct-2006'), 'N');
insert into attendance values (105, to_date('19-oct-2006'), 'N');
insert into attendance values (105, to_date('20-oct-2006'), 'Y');
insert into attendance values (105, to_date('23-oct-2006'), 'N');
insert into attendance values (105, to_date('24-oct-2006'), 'N');
insert into attendance values (105, to_date('25-oct-2006'), 'Y');
insert into attendance values (105, to_date('26-oct-2006'), 'Y');
insert into attendance values (105, to_date('27-oct-2006'), 'Y');
insert into attendance values (105, to_date('30-oct-2006'), 'Y');
insert into attendance values (105, to_date('31-oct-2006'), 'Y');
insert into attendance values (105, to_date('01-nov-2006'), 'N');
insert into attendance values (105, to_date('02-nov-2006'), 'N');
insert into attendance values (105, to_date('03-nov-2006'), 'Y');
Now the query to get each sick occurrence and the number of consecutive days for each employee is...
select empid, first_sick_day, sick_count from
(select empid,
first_value(business_day) over (partition by empid, groupno order by business_day) as first_sick_day,
row_number() over (partition by empid, groupno order by business_day) as rn,
count(*) over (partition by empid, groupno) as sick_count
from
(select empid, business_day, daynum-rownum groupno
from
(SELECT a.empid, a.business_day, d.day_num as daynum
FROM attendance a,
(select rownum as day_num, business_day
from (select business_day from business_dates order by business_day)) d
WHERE sick = 'Y' AND a.business_day = d.business_day
ORDER BY 1,2 )
where rn = 1;
The above query can be modified slightly to only give you the sick occurrence with the maximum number of consecutive days for each employee.
Having a separate date table is nice because you can take in account weekends, holidays or any other nonwork day by just removing that date from the table. Generating this table is easy as date dimension examples can be found on on the web, and the amount of rows is small (250 rows per year approx).
JR -
Count consecutive month reset if gap in months
I have been hitting a road block on a report I have been trying to create. I am looking to find the most recent consecutive months for a specific ID. If there is a break in the months the counter would restart. I have been able
to create this but when there is a gap in the months my counter is not resetting.
Here is a sample table:
Declare @CTE Table (ID int, datestamp datetime);
insert @CTE(ID, datestamp)
select 8, '2013-11-15 00:00:00.000'
union ALL select 8, '2013-12-16 00:00:00.000'
union ALL select 8, '2014-01-15 00:00:00.000'
union ALL select 15, '2013-09-16 00:00:00.000'
union ALL select 17, '2014-02-28 00:00:00.000'
union ALL select 51, '2013-05-10 00:00:00.000'
union ALL select 51, '2014-04-10 00:00:00.000'
union ALL select 52, '2013-12-26 00:00:00.000'
union ALL select 59, '2013-08-12 00:00:00.000'
union ALL select 59, '2014-01-13 00:00:00.000'
union ALL select 59, '2014-04-14 00:00:00.000'
union ALL select 59, '2014-05-12 00:00:00.000'
union ALL select 62, '2013-06-10 00:00:00.000'
union ALL select 62, '2013-06-20 00:00:00.000'
union ALL select 62, '2013-10-10 00:00:00.000'
union ALL select 62, '2013-11-12 00:00:00.000'
union ALL select 64, '2013-05-28 00:00:00.000'
union ALL select 64, '2013-06-27 00:00:00.000'
union ALL select 64, '2013-07-29 00:00:00.000'
union ALL select 66, '2013-07-26 00:00:00.000'
union ALL select 74, '2013-04-15 00:00:00.000'
union ALL select 74, '2013-05-15 00:00:00.000'
union ALL select 82, '2013-09-03 00:00:00.000'
union ALL select 92, '2013-04-15 00:00:00.000'
Here is my query I am having issues with.
WITH test AS
SELECT ID, datestamp,
ROW_NUMBER() OVER(PARTITION BY ID ORDER BY datestamp) AS X
FROM @CTE
SELECT
ID,
COUNT(X) AS number_of_payments,
MIN(datestamp) as Min_date,
MAX(datestamp) as Max_date
FROM test
GROUP BY ID
order by ID
I am looking for results as follows.
ID Count
8 3
15 1
17 1
51 1
52 1
59 2
62 2
64 3
66 1
74 2
82 1
92 1Desired would be a count of records so when the flag turns 0 the count resets. So since row_id 321737 had the flag return as 0 the counter would start after that.
I want to be able to see ID 5539 is currently at 3
row_id ID flag enter_date flag_date
419390 5539
1 2014-05-02
00:00:00.000
2014-05-08
00:00:00.000
386558 5539
1 2014-04-18
00:00:00.000
2014-04-24
00:00:00.000
351279 5539
1 2014-04-04
00:00:00.000
2014-04-10
00:00:00.000
321737 5539
0 2014-03-21
00:00:00.000 NULL
298751 5539
1 2014-03-11
00:00:00.000
2014-03-17
00:00:00.000
236830 5539
1 2014-02-11
00:00:00.000
2014-02-18
00:00:00.000
187083 5539
1 2014-01-13
00:00:00.000
2014-01-17
00:00:00.000
142108 5539
0 2013-12-11
00:00:00.000 NULL
93199 5539
0 2013-11-12
00:00:00.000 NULL
62720 5539
0 2013-10-11
00:00:00.000 NULL -
hi,
I had this requirement, to count number of consecutive appearance of a status for a particular period dynamically
with x as (
select 101 as "ID", '01' as "STATUS", '01-01-11' as "DT" from dual
union
select 101 as "ID", '02' as "STATUS", '01-02-11' as "DT" from dual
union
select 101 as "ID", '03' as "STATUS", '01-03-11' as "DT" from dual
union
select 101 as "ID", '02' as "STATUS", '01-04-11' as "DT" from dual
union
select 101 as "ID", '02'as "STATUS", '01-05-11' as "DT" from dual
union
select 101 as "ID", '03' as "STATUS", '01-06-11' as "DT" from dual
union
select 101 as "ID", '02' as "STATUS", '01-07-11' as "DT" from dual
union
select 101 as "ID", '02' as "STATUS", '01-08-11' as "DT" from dual
union
select 101 as "ID", '04' as "STATUS", '01-09-11' as "DT" from dual
union
select 101 as "ID", '03' as "STATUS", '01-10-11' as "DT" from dual
union
select 101 as "ID", '03' as "STATUS", '01-11-11' as "DT" from dual
union
select 101 as "ID", '03' as "STATUS", '01-12-11' as "DT" from dual)
select x.ID,x.STATUS,x.DT from x order by x.DT
<pre>
Output should be - ID 101 and STATUS '01' is not required
STATUS 1Time 2Time 3&4Time 5&above
02 1 2
03 2 1
04 1
</pre>
Columns 1Time, 2Time,3&4Time, 5&above means count the number of consecutive appearance of the status (have to check previous month status and next month status)
i.e for example if we take Status '02'
after checking previous month and next month status, Status '02' has appeared one time consecutively on '01-02-11'(Feb)
and hence 1 should come under '1Time' Column.
similarly after checking previous month and next month status, the number of 2 consecutive appearance of status '02' is twice, that is on ('01-04-11', '01-05-11') and ('01-07-11', '01-08-11'),hence the count of them will 2 under '2Time' column
For Status '03',
there are two one-time consecutive appearance of the Status, that is on '01-03-11' and '01-06-11'. Hence count is 2 under '1Time' column for status 03
and Status '03' has single 3 consecutive appearance, that is on '01-10-11', '01-11-11', '01-12-11', hence count is 1 under 3&4Time coulmn.
RegardsLike this?
-- Data:
with x as (
select 101 as "ID", '01' as "STATUS", '01-01-11' as "DT" from dual
union
select 101 as "ID", '02' as "STATUS", '01-02-11' as "DT" from dual
union
select 101 as "ID", '03' as "STATUS", '01-03-11' as "DT" from dual
union
select 101 as "ID", '02' as "STATUS", '01-04-11' as "DT" from dual
union
select 101 as "ID", '02'as "STATUS", '01-05-11' as "DT" from dual
union
select 101 as "ID", '03' as "STATUS", '01-06-11' as "DT" from dual
union
select 101 as "ID", '02' as "STATUS", '01-07-11' as "DT" from dual
union
select 101 as "ID", '02' as "STATUS", '01-08-11' as "DT" from dual
union
select 101 as "ID", '04' as "STATUS", '01-09-11' as "DT" from dual
union
select 101 as "ID", '03' as "STATUS", '01-10-11' as "DT" from dual
union
select 101 as "ID", '03' as "STATUS", '01-11-11' as "DT" from dual
union
select 101 as "ID", '03' as "STATUS", '01-12-11' as "DT" from dual)
-- Query:
select status, sum(decode(c,1,1,0)) "1 Time",
sum(decode(c,2,1,0)) "2 Time",
sum(decode(c,3,1,4,1,0)) "3 or 4 Time",
sum(case when c>=5 then 1 else 0 end) "5 or above"
from
select status, d, count(*) c
from
select x.ID,
x.STATUS,
to_date(x.DT,'MM-DD-RR')-row_number() over (partition by status order by dt) d
from x order by x.DT
group by status, d
group by status
order by status;If you like you may add the condition
where status!='01'Edited by: hm on 11.01.2012 22:40 -
Is it possible to count '0' events with 6229?
I have set up a buffed edge counting which works fine with our E-series
boards. Using a new NI 6229, however, the same program returns
minimally 1 count.
It seems that in the case that the signal frequency is
lower than that of the timebase (in our case ctr0 is producing pulses at a
frequency of 1kHz, ctr0out->ctr1gate, signal to be measured arrives
at ctr1source) the card completely ignores the timing. Example: with
1kHz at the gate I would expect to read 1000 datapoints per second; if
the signal runs at a lower frequency than 1kHz I read a number of
datapoints corresponding to the signal frequency (all value "1").
At higher signal frequency it seems to work as expected.
I have tried a different BNC-2110 box and switching the order of the
counters (ie using ctr1 as timing device and ctr0 as the actual
counter), but this problem remains.
The cabelling has been done according to the NI-6229 port/pin scheme
found in the documentation directory of Labview. (ctr0out is BNC on the
box, ctr1gate=pin41=PFI4 on the box, ctr1source=pin42=PFI3 on the box;
for opposite configuration ctr1out as on box, ctr0gate=pin 3=PFI9 on
box, ctr0source=pin 37=PFI8 on box).
I would be very thankful for any help with this,
Gerhard
my apologies for the cross-post, but I put this question first up in the wrong discussion board.The behavior you are seeing when no edges occur on your event counting terminal are the result of not enabling duplicate count prevention. In DAQ 7.4, the default behavior of duplicate count behavior should enable this for you by default, but if you cannot upgrade to DAQ 7.4, I'd enable "duplicate count prevention" attribute. There are a number of previous posts about this attribute, including this post.
I hope this helps!
gus.... -
Count consecutive instances of a particular value
is there a way to have numbers look at a colum and give me the number of the highest consecutive anserws. Here is the example I am dealing with.
I would like to have a total at the bottom of each column that will calculate the most consecutive right answers in each column. That way I can award a prize to the person that got the most correct in a row.
StacyHi Stacey,
That's an interesting challenge. Here's my approach:
There are two Header Rows, even though I made the formatting change to make the second header row look like a body row for consistency with the rest of the data. The reason I did that is so that you can expand the table and have the new rows automatically fill with the formulas of the body rows. Adding rows when all body rows are the same causes the autofill behavior. I needed the first data row to have a different equation, so I used a header for the first row of data.
So, here are the equations:
B2: =IF(B="Right", 1, 0)
B3 to the last body row: =IF(B="Right", C2+1, 0)
Column B's first Footer row:
=COUNTIF(B, "Right")+COUNTIF(B2, "Right")
Column B's second Footer row:
=COUNTIF(B, "Wrong")+COUNTIF(B2, "Wrong")
Column B's third Footer row:
=MAX(C, C2)
That's it.
Regards,
Jerry -
Counting consecutive numbers in a view
Say I have the following data in a table:
ID YEAR
1 2004
1 2005
1 2006
1 2008
1 2009
2 1998
2 1999
2 2000
Is there anyway to return a 3rd row in a query which would return a 1 if the previous rows YEAR was 1 different, but a 0 if otherwise. So the data would look like this:
ID YEAR COUNT
1 2004 0
1 2005 1
1 2006 1
1 2008 0
1 2009 1
2 1998 0
2 1999 1
2 2000 1
2 2001 1
2 2002 1
2 2006 0
I am basically trying to find out if someones yearly membership was a renewal. Here's the data:
with t1 as (select 1 as ID,2004 as YEAR from dual union
select 1,2005 from dual union
select 1,2006 from dual union
select 1,2008 from dual union
select 1,2009 from dual union
select 2,1998 from dual union
select 2,1999 from dual union
select 2,2000 from dual union
select 2,2001 from dual union
select 2,2002 from dual union
select 2,2006 from dual)
select ID,
YEAR
from t1
order by id, year;
Thanks,
AndrewThanks for providing sample data and expected results!
I think this is what you want.
SQL> with t1 as (select 1 as ID,2004 as YEAR from dual un
2 select 1,2005 from dual union
3 select 1,2006 from dual union
4 select 1,2008 from dual union
5 select 1,2009 from dual union
6 select 2,1998 from dual union
7 select 2,1999 from dual union
8 select 2,2000 from dual union
9 select 2,2001 from dual union
10 select 2,2002 from dual union
11 select 2,2006 from dual)
12 SELECT ID
13 , YEAR
14 , (CASE
15 WHEN YEAR - LAG(YEAR) OVER (PARTITION BY ID ORDER BY YEAR) = 1
16 THEN 1
17 ELSE 0
18 END) AS RENEWAL
19 FROM t1
20 ORDER BY ID
21 , YEAR
22 /
ID YEAR RENEWAL
1 2004 0
1 2005 1
1 2006 1
1 2008 0
1 2009 1
2 1998 0
2 1999 1
2 2000 1
2 2001 1
2 2002 1
2 2006 0
11 rows selected. -
hi all..
I'm new to Labview. I'm trying to figure out how to count the number of times a sine waveform reaches a certain amplitude value and displaying it on the front panel. Could somebody please guide me to do this.This one does what I think you want.
Tim
Johnson Controls
Holland Michigan
Attachments:
Find Peaks.vi 15 KB -
Hi everyone,
I'm building a heart rate monitor as a final year project with my lab partner using the NI USB-6009 and Labview 2009. We have managed to obtain a signal using a photo transciever, smooth it out and count the events, however the count is incremental.
We wish to count the number of pulses we obtain for a few seconds (5-10 for example) and then use this value to obtain a pulse rate in beats per minute (e.g. 10 pulses in the first 10 seconds would give an estimated BPM of 60 etc etc).
Does anybody have ides on how we could implement this? We have tried timed loops, elapsed time VI's and other things but nothing gives us what we need.
Thanks in advance for any help that is offered.
Jeshua Graham.We are very new to Labview. We are taking a raw signal from our DAQ and then using VIs to filter and then trigger counts on rising edges. I have attached our vi file to this post for you to look at (I hope that is what you mean by code).
Attachments:
TCRT-1010DAQ_jeshua1.vi 367 KB
Maybe you are looking for
-
I have a new laptop and i have authorized it with my apple ID but I can't sync my iphone with it because it is currently synced to another computer. Every time I try and sync my music it comes up with the message ' are you sure you want to remove ex
-
Acrobat Crashes when signing a document
I have Acrobat 8.1.7 professional and all of a sudden I am unable to digitally sign documents. When I attempt to sign a document, the "sign document" dialog box opens, freezes and the acrobat closes down. Can someone assist me with this issue? Window
-
Before I did have the game and my screen was fine and there were no problems and now there are. Plus whenever I close my computer with the game on it makes a loud screeching noise.
-
I can't put the photo in my iPod
I used the iTunes to sync the photos into my nano. But it showed "Updating iPod.Do not disconnect" for a long,long time. The photos did not sync to my iPod. How can I do?
-
Hello, Since December 2014 my phone camera has not been working. A few times I would restart, and it would work again for a day or so, then it would stop working again. I get 3 different error messages (screenshots attached in this message). The