How to group value in certain range ?
Hi all,
I have an ArrayList of double value (0.143554,0.999741,1.032341,4.976403,5.008995,8.973876,9.006459,
12.99214,13.03558,16.98777,17.0312,20.98247,21.03674,24.99796,
25.04136,28.99081,29.06675,32.96105,33.01528)
and I want to group the value to the closest 5 (starting from the minimum
value(0) of the list and ending at the maximum value(35) of the list).
Example :
0.143554 should become 0 (0.143554 < 0.5)
0.999741 should become 5 (0.5 <= 0.999741 < 5.5)
1.032341 should become 5 (0.5 <= 1.032341 < 5.5)
4.976403 should become 5 (0.5 <= 4.976403 < 5.5)
5.008995 should become 5 (0.5 <= 5.008995 < 5.5)
8.973876 should become 10 (5.5 <= 8.973876 < 10.5)
9.006459 should become 10 (5.5 <= 9.006459 < 10.5)
12.99214 should become 15 (10.5 <= 12.99214 < 15.5)
13.03558 should become 15 (10.5 <= 13.03558 < 15.5)
16.98777 should become 20 (15.5 <= 16.98777 < 20.5)
17.0312 should become 20 (15.5 <= 17.0312 < 20.5)
20.98247 should become 25 (20.5 <= 20.98247 < 25.5)
21.03674 should become 25 (20.5 <= 21.03674 < 25.5)
24.99796 should become 25 (20.5 <= 24.99796 < 25.5)
25.04136 should become 25 (20.5 <= 25.04136 < 25.5)
28.99081 should become 30 (25.5 <= 28.99081 < 30.5)
29.06675 should become 30 (25.5 <= 29.06675 < 30.5)
32.96105 should become 35 (30.5 <= 32.96105 < 35.5)
33.01528 should become 35 (30.5 <= 33.01528 < 35.5)
How could I do that..? Thanks
Edited by: azlicn on Jun 8, 2008 9:03 PM
0.143554 should become 0 (0.143554 < 0.5)
0.999741 should become 5 (0.5 <= 0.999741 < 5.5)
1.032341 should become 5 (0.5 <= 1.032341 < 5.5)
4.976403 should become 5 (0.5 <= 4.976403 < 5.5)
5.008995 should become 5 (0.5 <= 5.008995 < 5.5)
8.973876 should become 10 (5.5 <= 8.973876 < 10.5)
9.006459 should become 10 (5.5 <= 9.006459 < 10.5)
12.99214 should become 15 (10.5 <= 12.99214 < 15.5)
13.03558 should become 15 (10.5 <= 13.03558 < 15.5)
16.98777 should become 20 (15.5 <= 16.98777 < 20.5)
17.0312 should become 20 (15.5 <= 17.0312 < 20.5)
20.98247 should become 25 (20.5 <= 20.98247 < 25.5)
21.03674 should become 25 (20.5 <= 21.03674 < 25.5)
24.99796 should become 25 (20.5 <= 24.99796 < 25.5)
25.04136 should become 25 (20.5 <= 25.04136 < 25.5)
28.99081 should become 30 (25.5 <= 28.99081 < 30.5)
29.06675 should become 30 (25.5 <= 29.06675 < 30.5)
32.96105 should become 35 (30.5 <= 32.96105 < 35.5)
33.01528 should become 35 (30.5 <= 33.01528 < 35.5)You just wrote the logic right there, put it in a switch statement and there ya have it.
Similar Messages
-
How to display value withing some range?
Hi,
I am trying to display months name using map and my results are as below:-
1)January
2)February
3)March
4)April
5)May
6)Jun
Now I want to display the result in some range i.e. display from 2) to 5) or from 4) to 9); whatever user inputs the range.
So how can I achieve this?
Regards,
PrateekHi,
With the help of Range droplet I am able to set the limit of my month list like if I give the value as 3 in howmany parameter;it shows the following result-
1)january
2)february
3)march
But as I said previously how can I show te result as below if user gives some input like (3-4):-
3)march
4)april
5)march
Thanks. -
How to group values in a column in ALV Grid
Hi ,
i have got a report layout like below.
1 4
1 5
1 6
2 7
2 8
2 8
now i want to group the 1st column like below
1 4
5
6
2 7
8
8
How can i get this in ALV grid display.....pls help me out if any of u have got a sample code.Hi,
Here is a sample program which shows how to do sorting.
report zsudheer
no standard page heading.
type-pools slis.
data: fieldcat type slis_t_fieldcat_alv.
<b>data: sort type slis_t_sortinfo_alv.</b>
data: begin of imara occurs 0,
matnr type mara-matnr,
matkl type mara-matkl,
labor type mara-labor,
brgew type mara-brgew,
maktx type makt-maktx,
end of imara.
* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.
start-of-selection.
perform get_data.
perform write_report.
* Get_Data
form get_data.
select mara~matnr mara~matkl mara~labor mara~brgew makt~maktx
into corresponding fields of table imara
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
endform.
* WRITE_REPORT
form write_report.
perform build_field_catalog.
<b>perform build_sort.</b>
* CALL ABAP LIST VIEWER (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_sort = sort
it_fieldcat = fieldcat
tables
t_outtab = imara.
endform.
* BUILD_FIELD_CATALOG
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
clear: fieldcat. refresh: fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material Number'.
fc_tmp-fieldname = 'MATNR'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '18'.
fc_tmp-col_pos = 2.
append fc_tmp to fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material Group'.
fc_tmp-fieldname = 'MATKL'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '12'.
fc_tmp-col_pos = 3.
append fc_tmp to fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Sort Group'.
fc_tmp-fieldname = 'LABOR'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '12'.
fc_tmp-col_pos = 3.
append fc_tmp to fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Gross Weight'.
fc_tmp-fieldname = 'BRGEW'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '12'.
fc_tmp-do_sum = 'X'.
fc_tmp-col_pos = 4.
append fc_tmp to fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material Description'.
fc_tmp-fieldname = 'MAKTX'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '40'.
fc_tmp-col_pos = 5.
append fc_tmp to fieldcat.
endform.
* FORM build_sort *
form build_sort.
data: tmp_sort type line of slis_t_sortinfo_alv.
clear sort. refresh sort.
<b> clear tmp_sort.
tmp_sort-fieldname = 'MATKL'.
tmp_sort-tabname = 'IALV'.
tmp_sort-up = 'X'.
append tmp_sort to sort.
clear tmp_sort.
tmp_sort-fieldname = 'LABOR'.
tmp_sort-tabname = 'IALV'.
tmp_sort-up = 'X'.
tmp_sort-subtot = 'X'.
append tmp_sort to sort.</b>
endform.
Regards,
Sudheer -
How to "group by" over a range?
hi
I have a table like this:
x y AMNT
1 120 12
1 120 93
1 125 31
1 260 15
2 56 16
2 115 49
3 45 71
4 19 11
4 16 48
5 94 52
5 98 47
I want to group records on x , y columns and aggregate on amnt column, in which difference between values of y column be less than 10.
The result is like this:
x y sum(AMNT)
1 ? 136
1 260 15
2 56 16
2 115 49
3 45 71
4 ? 59
5 ? 99
What query can I use?Like this
"afiedt.buf" 25 lines, 901 characters
1 with t
2 as
3 (
4 select 1 x, 120 y, 12 amt from dual union all
5 select 1, 120, 93 from dual union all
6 select 1, 125, 31 from dual union all
7 select 1, 260, 15 from dual union all
8 select 2, 56 , 16 from dual union all
9 select 2, 115, 49 from dual union all
10 select 3, 45 , 71 from dual union all
11 select 4, 19 , 11 from dual union all
12 select 4, 16 , 48 from dual union all
13 select 5, 94 , 52 from dual union all
14 select 5, 98 , 47 from dual
15 )
16 select x, case when max(cnt) = 1 then to_char(min(y)) else '?' end y, sum(amt) amt
17 from (
18 select x, y, amt, y_next, case when y - y_next <= 10 then 1 else 0 end y_ind, count(*) over(partition by x, case when y - y_next <= 10 then 1 else 0 end) cnt
19 from (
20 select x, y, amt, nvl(lag(y) over(partition by x order by y), y) y_next
21 from t
22 )
23 )
24 group by x, y_ind
25* order by 1,2 desc
SQL> /
X Y AMT
1 ? 136
1 260 15
2 56 16
2 115 49
3 45 71
4 ? 59
5 ? 99
7 rows selected.
SQL> -
Subreport data use to group Values in Main Report
Hello,
I create a Subreport in my header to calculate values, the formula is based on a specific sorting and comparison of previous values.
In my main report I need to Group my values depending on the result. Because the group I will made on the Main Report can't be the same sorting of the SubReport.
SUB-REPORT
1 Paris (result "Capital")
2 Lille (result "Same Country of Paris")
3 Lyon (result "Same Country of Paris")
4 London (result "Capital")
5 Manchester ("Same Country of London")
MAIN-REPORT
Group
- CAPITAL (Paris, London)
- Same Country of London (Manchester)
- Same Country of Paris (Lille, Lyon)
My issue, is that I don't know how to group values on MainReport based on a formula Result of the SubReport
OR, may be there is a way to search on value in the sub-report ?You can't use a shared variable to group on from a sub report in the main report since a shared variable evaluation time is done whileprintingrecords.
Try using a SQL expression to return the same result as the subreport would. You can then group on the SQL expression
Edited by: Zilla Eh on Jan 15, 2009 6:39 PM -
How to pass value to select-option parameter using SET PARAMETER Command
Hi,
Am passing values to selection-screen fields in report RV13A004 ( used in VK11, VK12 and VK13). using below statement but material number is select-option in this report. am able to pass MATERIAL FROM using SET PARAMETER ID, can i know how to pass values MATERIAL TO range in select-options fields using SET PARAMETER Command ??
Passing values to parameter id
set parameter id 'VKS' field kschl.
set parameter id 'VKO' field vkorg.
set parameter id 'VTW' field vtweg.
set parameter id 'KDA' field erdat.
set parameter id 'MAT' field matnr_from.
Change condition price.
call transaction 'VK12' and skip first screen.
Thanks in advance.
Regards,
Balamurugan.Hi,
instead of using set parameters and dden call transaction use this..........
submit RV13A004 WITH SELECTION-TABLE rspar
Effect
If you specify this addition, parameters and selection criteria on the selection screen are supplied from an internal table rspar. You must specify an internal table with the row type RSPARAMS for rspar. The structured data type RSPARAMS is defined in the ABAP Dictionary and has the following components, all of which are data type CHAR:
SELNAME (length 8),
KIND (length 1),
SIGN (length 1),
OPTION (length 2),
LOW (length 45),
HIGH (length 45).
To supply parameters and selection criteria for the selection screen with specific values, the lines in the internal table rspar must contain the following values:
SELNAME must contain the name of a parameter or selection criterion for the selection screen in block capitals
KIND must contain the type of selection screen component (P for parameters, S for selection criteria)
SIGN, OPTION, LOW, and HIGH must contain the values specified for the selection table columns that have the same names as the selection criteria; in the case of parameters, the value must be specified in LOW and all other components are ignored.
If the name of a selection criterion is repeated in rspar, this defines a selection table containing several lines and passes it on to the selection criterion. If parameter names occur several times, the last value is passed on to the parameter.
The contents of the parameters or selection tables for the current program can be entered in the table by the function module RS_REFRESH_FROM_SELECTOPTIONS.
Notes
In contrast to selection tables, the data types of the components LOW and HIGH in table rspar are always of type CHAR and are converted to the type of the parameter or selection criterion during transfer, if necessary.
When entering values, you must ensure that these are entered in the internal format of the ABAP values, and not in the output format of the screen display.
Cheers
Will. -
How to assign attribute values to a range of BPs ????
Hi All,
While assigning attribute values to business partners we can specify at the most one business partner at a time.
My requirement is to assign attribute values to a range of business partners at a time.
Is there any customization setting where I can do this OR
do I write a report for this ?
Regards,
AshishHi Ravi,
Thanks for replying !!!!
But, CRMD_MKT_TOOLS doesnt seem to solve my problem.
I have a range of BPs (e.g 8000101 to 8000199).
And I have a list of attribute sets with values as follows:-
Attribute Set Values
Age group 1 - 10, 11 - 20, ....
Reading habits Business, sports, news.....
Profession Doctor , Engineer .......
and so on..
Now in transaction CRMD_PROF_BP, I can choose a single BP (e.g. 8000101) and assign it an attribute set(e.g. Profession) and value (Doctor).
But, my requirement is to specify an entire range of BPs(8000101 to 8000150) and assign attribute set and values to that entire range.
Now how do I achieve this ???????
(target groups would be created only after attributes have been assigned)
Regards,
Ashish -
How to find roles with certain org field values?
agr_1252 holds its values in Low and High fields. So if I want to discover roles giving visibility to certain $RSINFOAREA such as LRDR* and MRT, how to do it? Most roles in our system use ranges in the org.fields, such as 0DA - ZL*, so I would need to identify these and change the ranges to prevent visibility to our sensitive infoareas. But I don't see a way to do this with SQVI and there are no canned reports in SUIM. Has anyone faced and solved this b4?
Hi
It seems to me at least on my system that RSINFOAREA is not an org element field - and in your landscape it has been changed into an org field. You can receive values of RSINFOAREA field either from agr_1251 or agr_1252 - depending upon the status of the field. Now after you have obtained value in ranges - you can see the exact individual values contained in ranges through table RSDAREA (Directory of InfoAreas) - hope this will help you.
Best Regards
Prashant -
How to get top 11 values per date range
I want to get the top 11 values by date range.
Sample Data
CREATE TABLE SAMPLE_DATA
DOMAIN_NAME VARCHAR2(100),
QTD NUMBER,
LOAD_DATE DATE
-- Insert
BEGIN
FOR lc IN 1..20
LOOP
FOR ld IN 1..30
LOOP
INSERT
INTO SAMPLE_DATA VALUES
'DM_'
||lc,
round(dbms_random.value(0,1000)),
SYSDATE-ld
END LOOP;
END LOOP;
COMMIT;
END;
SELECT *
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM SAMPLE_DATA
WHERE LOAD_DATE = TRUNC(SYSDATE-3)
ORDER BY QTD DESC
WHERE ROWNUM <=10
UNION ALL
SELECT 'Others' DOMAIN_NAME,
SUM(QTD) QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT rownum rn,
DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM SAMPLE_DATA
WHERE LOAD_DATE = TRUNC(SYSDATE-3)
ORDER BY QTD DESC
WHERE rn > 10
GROUP BY LOAD_DATE
ORDER BY QTD DESC
-- Result
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/13
DM_1 1000 24/03/13
DM_20 933 24/03/13
DM_11 913 24/03/13
DM_3 743 24/03/13
DM_13 572 24/03/13
DM_12 568 24/03/13
DM_9 564 24/03/13
DM_6 505 24/03/13
DM_5 504 24/03/13
DM_2 480 24/03/13
Please, Help me get in one query this result using a range of date.
e.g
using LOAD_DATE BETWEEN '24/03/13' AND '25/03/13'
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/13
DM_1 1000 24/03/13
DM_20 933 24/03/13
DM_11 913 24/03/13
DM_3 743 24/03/13
DM_13 572 24/03/13
DM_12 568 24/03/13
DM_9 564 24/03/13
DM_6 505 24/03/13
DM_5 504 24/03/13
DM_2 480 24/03/13
Others 1948 25/03/13
DM_1 807 25/03/13
DM_8 764 25/03/13
DM_7 761 25/03/13
DM_11 656 25/03/13
DM_18 611 25/03/13
DM_17 523 25/03/13
DM_14 467 25/03/13
DM_19 447 25/03/13
DM_15 437 25/03/13
DM_6 380 25/03/13 Thank you in advance.I got the solution. Just sharing.
I used analytic functions that make my job easy.
Sample Data
DOMAIN_NAME QTD LOAD_DATE
DM_1 807 25/03/2013
DM_1 1000 24/03/2013
DM_2 226 25/03/2013
DM_2 480 24/03/2013
DM_3 244 25/03/2013
DM_3 743 24/03/2013
DM_4 48 25/03/2013
DM_4 413 24/03/2013
DM_5 164 25/03/2013
DM_5 504 24/03/2013
DM_6 380 25/03/2013
DM_6 505 24/03/2013
DM_7 761 25/03/2013
DM_7 212 24/03/2013
DM_8 764 25/03/2013
DM_8 308 24/03/2013
DM_9 354 25/03/2013
DM_9 564 24/03/2013
DM_10 214 25/03/2013
DM_10 367 24/03/2013
DM_11 656 25/03/2013
DM_11 913 24/03/2013
DM_12 37 25/03/2013
DM_12 568 24/03/2013
DM_13 332 25/03/2013
DM_13 572 24/03/2013
DM_14 467 25/03/2013
DM_14 87 24/03/2013
DM_15 437 25/03/2013
DM_15 450 24/03/2013
DM_16 238 25/03/2013
DM_16 299 24/03/2013
DM_17 523 25/03/2013
DM_17 143 24/03/2013
DM_18 611 25/03/2013
DM_18 145 24/03/2013
DM_19 447 25/03/2013
DM_19 464 24/03/2013
DM_20 91 25/03/2013
DM_20 933 24/03/2013 Top 11 QTD of DOMAIN_NAME per Data Range.
SELECT *
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT LOAD_DATE,
DOMAIN_NAME ,
QTD,
(DENSE_RANK() OVER (PARTITION BY LOAD_DATE ORDER BY QTD DESC )) AS RANK_QTD
FROM SAMPLE_DATA
WHERE trunc(load_date) BETWEEN '24/03/2013' AND '25/03/2013'
WHERE RANK_QTD <= 10
UNION ALL
SELECT 'Others',
SUM(QTD) AS QTD,
LOAD_DATE
FROM
(SELECT LOAD_DATE,
DOMAIN_NAME ,
QTD,
(DENSE_RANK() OVER (PARTITION BY LOAD_DATE ORDER BY QTD DESC )) AS RANK_QTD
FROM SAMPLE_DATA
WHERE trunc(load_date) BETWEEN '24/03/2013' AND '25/03/2013'
WHERE RANK_QTD > 10
GROUP BY LOAD_DATE
ORDER BY LOAD_DATE ASC,
QTD DESC
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/2013
DM_1 1000 24/03/2013
DM_20 933 24/03/2013
DM_11 913 24/03/2013
DM_3 743 24/03/2013
DM_13 572 24/03/2013
DM_12 568 24/03/2013
DM_9 564 24/03/2013
DM_6 505 24/03/2013
DM_5 504 24/03/2013
DM_2 480 24/03/2013
Others 1948 25/03/2013
DM_1 807 25/03/2013
DM_8 764 25/03/2013
DM_7 761 25/03/2013
DM_11 656 25/03/2013
DM_18 611 25/03/2013
DM_17 523 25/03/2013
DM_14 467 25/03/2013
DM_19 447 25/03/2013
DM_15 437 25/03/2013
DM_6 380 25/03/2013 -
How can I show a 0% range in the data value label on a bar chart thanks?
How can I show a 0% range in the data value label on a bar chart thanks?
I'm not sure what the question is.
I know that if you have a bar chart and one of the categories (X-axis) has bar (Y value) equal to 0%, no bar is plotted for that category. Even the addition of a stroke (line) around the bars doesn't make one appear for 0%. The only automatic way I know of to make it look like there is data in that category is to add the value labels to the bars. Inspector/Chart/Series, select one of the bars on the chart, click on "value labels". Another method that is a workaround is to fudge the number a little in your table so that instead of 0% it is a very small %. This will get you a thin line on the chart.
But if your question is about the value labels (the numbers that display on or in the bars) and you are not getting one for a bar that is supposed to be 0%, it probably means your table doesn't actually have a 0% in the corresponding cell. A blank cell in the table will not get a value label. -
How to assign values to server group when you parallelly client-copying
Hello all,
I'm now trying to create server group.
Currently, I use serial process, or default settings, when client-copying.
But I want to implement this in parallel processes.
Due to this, I have to create server group and assign a lot of values to something I don't know!
I want to create a server group, but don't know how to assign values to ones like "Max. requests in queue", "Max. no of logons" and so on.
Could you please advise me how to allocate values to the resourses shown below;
Advanced : 1 *I think "1" is the flag for advanced settings
Max. requests in queue
Max. no. of logons
Max. disp. of own logon
Max. no. of WPs used: *should be the total of SM50, I guess
Min. no. of free WPs
Max. no. of comm. entries
Max. wait time
thanks in advance,
HozyHi,
Would you check this [Parallel Processes |http://help.sap.com/saphelp_sm32/helpdata/EN/e8/df959834ac11d586f90000e82013e8/frameset.htm] and [Parallel processes FAQ|http://www.saptechies.com/ccinfo-parallel-processes-faq/] i hope will get some hint.
Regards
Mohan Rao -
How to group the values with this partition over clause ?
Hi,
I have a nice request :
select c.libelle "Activité", sum(b.duree) "Durée"
from fiche a, activite_faite b,
activites c, agent d
where a.date_activite
BETWEEN TO_DATE('20/09/2009', 'DD/MM/YYYY') AND TO_DATE('26/10/2009', 'DD/MM/YYYY')
AND a.agent_id = 104
AND a.fiche_id = b.fiche_id
AND b.activites_id = c.activites_id
AND a.agent_id = d.agent_id
group by c.libelle
order by sum(b.duree)It gives me this nice result :
ACTIVITE DUREE
Tonte 27I want to get a percentage, i use ratio_to_report
select a.fiche_id, c.libelle "Activité", ratio_to_report(duree) over (partition by c.activites_id) * 100 "Durée"
from fiche a, activite_faite b,
activites c, agent d
where a.date_activite
BETWEEN TO_DATE('20/09/2009', 'DD/MM/YYYY') AND TO_DATE('26/10/2009', 'DD/MM/YYYY')
AND a.agent_id = 104
AND a.fiche_id = b.fiche_id
AND b.activites_id = c.activites_id
AND a.agent_id = d.agent_idIt gives me this less nice result :
Tonte 7,40740740740740740740740740740740740741
Tonte 33,33333333333333333333333333333333333333
Tonte 33,33333333333333333333333333333333333333
Tonte 25,92592592592592592592592592592592592593I would like to get this result :
Tonte 100I tried "grouping" values in the partition over clause but without success.
Any help appreciated from the slq-masters :
Regards,
ChristianChristian from France wrote:
I would like to get this result :
Tonte 100
Hi,
Why not this
select c.libelle "Activité", 100 "Durée"
from fiche a, activite_faite b,
activites c, agent d
where a.date_activite
BETWEEN TO_DATE('20/09/2009', 'DD/MM/YYYY') AND TO_DATE('26/10/2009', 'DD/MM/YYYY')
AND a.agent_id = 104
AND a.fiche_id = b.fiche_id
AND b.activites_id = c.activites_id
AND a.agent_id = d.agent_id
group by c.libelle
order by sum(b.duree)Because it would always be 100 (if you are taking as percentage) be what ever the count of duree be.
Or did I miss something in understanding the requirement.
Regards
Anurag -
Counting the number of pixels in a certain range within an ROI
I am using Vision 6.0 for Visual Basic.
I would like to get a count of the number of pixels within a particular region whose value falls within a certain range (e.g., the number of pixels with values between 86 and 255).
Can anyone tell me how I can do this?
Thanks.bep -
Have you looked at the Histogram example? It should be under the Analysis directory wherever the examples are.
After doing the Histogram like the example does, you will have a CWIMAQHistogramReport object (let's call it HistogramReport) that contains the result of the Histogram. To access the 1-dimensional array containing the count in each bin, use the Histogram property on the CWIMAQHistogramReportItem that the HistogramReport contains.
To use this array, however, you will need to assign it to a variant. So, to find the number of pixels that are in the 5th bin (with the default options, this will be the pixels that have exactly the value 4), do
Dim Histogram As Variant
Dim HistogramReport As New CWIMAQHistogramReport
CWIMA
QVision1.Histogram2 CWIMAQViewer1.Image, HistogramReport
Histogram = HistogramReport(1).Histogram
' Now Histogram(5) contains the number of pixels in the 5th bin.
Let me know if this helps.
Greg Stoll
IMAQ R & D
National Instruments
Greg Stoll
LabVIEW R&D -
How can we restrict the date range in the date picker
While selecting any date a pop up date picker appears. In this date picker the users can select any future dates which can be 30-40 yrs ahead. How can customize this date picker so that the users are not allowed to slected date beyond certain range. ...??
Hi user570596,
I think there is no method to actually restrict the date picker popup, but you can use the ApexLib Framework (http://apexlib.sourceforge.net/) to define a min/max value for your date field. This will prevent the user from submitting the page when the date value is outside the defined range.
See http://inside-apex.blogspot.com/2007/03/min-max-value-validation-in-browser.html
for details.
Patrick
Check out my APEX-blog: http://inside-apex.blogspot.com
Check out the ApexLib Framework: http://apexlib.sourceforge.net -
How do I collapse contiguous Date Ranges in SQL?
Hi,
In the data below, I want to collapse the contiguous date ranges with the same value (3.7) into a single date range. I have tried and tried to come up with something but am stuck. Does anyone know how to accomplish?
DECLARE @Have TABLE(B DATE, E DATE, R DECIMAL(18, 1))
INSERT INTO @Have VALUES
('2014-08-22', '2014-12-31', 4.0)
, ('2015-01-01', '2015-03-29', 3.7) -- same value, contingious date ranges
, ('2015-03-30', '2015-03-31', 3.7) -- same value, contingious date ranges
, ('2015-04-01', '2015-09-30', 4.0)
SELECT * FROM @Have
DECLARE @Want TABLE(B DATE, E DATE, R DECIMAL(18, 1))
INSERT INTO @Want VALUES
('2014-08-22', '2014-12-31', 4.0)
, ('2015-01-01', '2015-03-31', 3.7) -- want to collapse into 1 date range
, ('2015-04-01', '2015-09-30', 4.0)
SELECT * FROM @Want
ThanksHi tballard,
The posts from Jingyang and Cooper would be perfect only in the case that there’s no date gap between your rows. In addition to their posts, if in any case there would be a gap, please refer my code below, which works in either case.
DECLARE @Have TABLE(B DATE, E DATE, R DECIMAL(18, 1))
INSERT INTO @Have VALUES
('2014-08-22', '2014-12-30', 3.7) --same value , date gap
, ('2015-01-01', '2015-03-29', 3.7) -- same value, contingious date ranges
, ('2015-03-30', '2015-03-31', 3.7) -- same value, contingious date ranges
, ('2015-04-01', '2015-09-27', 4.0) --same value, date gap
, ('2015-10-1', '2015-12-30', 4.0) --same value, date gap
;WITH CTE1 AS(
SELECT H1.B B1,H1.E E1,H1.R R1,H2.B B2,H2.E E2,ISNULL(H2.R,0) R2,ROW_NUMBER() OVER(ORDER BY H1.B) RN FROM @HAVE H1 LEFT JOIN @HAVE H2 ON DATEDIFF(DAY,H1.B,H2.E)=-1
CTE2 AS(
SELECT B1,E1,R1 FROM CTE1 WHERE R1 != R2
CTE3 AS(
SELECT B1,E1,RN,B2 FROM CTE1 WHERE R1=R2
CTE4 AS(
Select min(B2) B, Max(E1) E from (
SELECT B2,E1,RN-row_number() Over(Order by B1) groupByCol
FROM CTE3
) t
Group by groupByCol
SELECT
C2.B1,ISNULL(C4.E,C2.E1),C2.R1
FROM CTE2 C2 LEFT JOIN CTE4 C4 ON C2.B1=C4.B
If you have any question, feel free to let me know.
Best regards,
Eric Zhang
Maybe you are looking for
-
Difference in Maintenance Plan date to Order basic start date
If i creat a strategy plan and schedule, i am getting difference in PLan date in Maint plan to Basic start date. What is making this difference. How to overcome this. I need Order start date same as PLan date. Plz help me frnds. Guruprasad
-
Accessing functions in an existing DLL
I have waded through stacks of info about how to use the JNI to access native functions etc. I have written my class and compiled it, created the header file, written the c++ code to call the DLL but I fall at the last hurdle when I try to create the
-
Cannot find specified file?
so i just got a 30 gig 5gen iPod a couple days ago. i went to link it with my PC, and a screen pops up and says "an error occured during the installation of this device The system could not find the file specified" iTunes dosen't see it, neither does
-
Problems installing ADF feature in JDeveloper 11.1.2.3
Hi everybody, I'm trying to install the ADF Mobile feature in two different windows XP SP3 computers, and allways get the same error. (last version of JDeveloper 11.1.2.3, studio and java edition) Installing the feature via update center or via Local
-
Wich MacOS is the best for Power Mac G5?
Wich MacOS Can I update to a Power Mac G5? Somebody told me that the last one that I can update is the 10.5.8, maybe I can update it for a newest version but it can give me some troubles, is it true?