Compare current value with previous value
Hello,
I would like to compare the current value with the previous value of the current value.
How can I solve this problem?
Maurits
Hi,
after going through the basics course you surely can understand that example:
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Similar Messages
-
How to compare current date with past date
Sample code for comparing current date with past date
i dont want to Calender.set method to compare it.
How can i do it?PLEASE stay with ONE thread:
http://forum.java.sun.com/thread.jspa?threadID=5143991&tstart=0 -
How to compare, current value in :block.text_item with the database value
Hi
Could you please tell me
How to compare the current value in :block.text_item with the corresponding database column value.
I am using forms 10g
There is block and there is an text Item in that block.
When I run the form and query the block (tabular), the :block.text_item shows me, whatever value there in the database.
Now I add some value in the :block.text_item to the existing value.
now
the :block.text_item contains old+ new added value
whereas
the database table contains 'old' value
Now on a button click , I want to find out what is the value that I have added
Could you please tell me, is it possible without writing a select query?Hello,
Now on a button click , I want to find out what is the value that I have addedSo you mean always user will add value in the existing value. Because this way will fail in one case. Let say
Value in Database is = ABCD
User opened the form and he removed the D and write E and now value is ABCE and length is still same 4. So, there is no addition.
Anyway you can know the database value at runtime there is one property for item called DATABASE_VALUE. It gives the value which is in database while you are running the form before save. and you can use like this..
Trigger = WHEN-MOUSE-DOUBLE-CLICK on item level
DECLARE
vItemValue DATATYPE; -- Set the data type according to your desired field.
vValueAdded DATATYPE; -- Set the data type according to your desired field.
BEGIN
vItemValue:=GET_ITEM_PROPERTY('ITEM_NAME',DATABASE_VALUE); -- It will return you the database value in vItemValue variable.
IF LENGTH(vItemValue)>LENGTH(:FORM_ITEM_NAME) THEN -- It mean something change or added
vValueAdded:=SUBSTR(:FORM_ITEM_NAME,LENGTH(vItemValue)+1);
MESSAGE('Added value is : '||vValueAdded); -- It will show you the added value.
END IF;
-- now suppose you want to show the old and new value in message not the added one
-- Then no need of IF condition. You can just use message like this
-- And i would prefer to use like this way
MESSAGE('Old Value : '||vItemValue||' New Value - '||:FORM_ITEM_NAME);
MESSAGE('Old Value : '||vItemValue||' New Value - '||:FORM_ITEM_NAME);
END;Hope it is clear.
-Ammad -
Compare current date with dat from db by JSTL
hi all
I use
<tr><c:forEach items="${allFound}" var="found" varStatus="myRow">
<td><c:out value="${found.submitDate}"/></td>
</tr>
</c:forEach>
to past some value out of db
how can I compare this submitDate with Current Date by JSTL
Thank you!Whether or not you can compare it depends on what the type of "${found.submitDate} is coming from the Database.
I am going to presume it is a java.util.Date.
You can get the current date like this
<jsp:useBean id="now" class="java.util.Date"/>
You can then compare them using an EL expression:
{code}
<c:if test="${submitDate < now}">
We have not yet reached the submit date.
</c:if>{code}
EL uses the java compareTo methods, so both of your objects +must+ be of the same class in order for this comparision to work.
If you get back a String from the database, you would have to use <fmt:parseDate> to get a java date.
If you get back a java.sql.Date from the database, it would get trickier. The hack would be to go java.sql.Date -> String -> java.util.Date using <fmt:formatDate> and <fmt:parseDate>
Hope this helps,
evnafets -
How to compare current time with any particular time?
Hi All,
Problem:
I have a form which accept data from user but i want that user can enter data only before 4 in the evening after that no data will be accepted and user get any message. Now the problem is I want to compare the current time with 4 o clock or 16:00:00 but i dont know how to check whether the current time is greater or lesser than 4. Till now my code are like this: if(tt.equals("16:00:00")){}else{}
where tt is current time. but this is not the feasible solution for my second clause.
Any kind of help will greatly appreciate.
ThanksOne more thing:
I find timestamp class quite helpful in my case but i
dont know how to implement the before() method
of this class.
Any idea.* You wouldn't implement before(). You'd just use it. It's already implemented for you.
* before() doesn't just compare the hour of the day. It compare two date & time objects to see which one is greater--that is, it effectively looks at all the fields, not just HOUR.
* You don't need Timestamp if you're not dealing with a database. -
How to compare Sale data with Previous data
Hi Guys,
Any one tell me how we will compare Sales data with Last year Sale data. Is there any T.Code or any kind of Report in the SAP. If available please suggest the same.
Thanks & regards,
Naveen BhatiaHi Naveen,
Did yo ucheck t-code SD01
Regards
Rohit. -
Compare - Current Data with Perious Data.
Experts,
We have created default report like below
Date - Company - Product - SCode - Amt Spent - Net Amt - Calls
12/12/2010 C1 P1 Code1 1000 1500 15
13/12/2010 C2 P4 Code2 1500 1200 10
12/12/2009 C1 P3 Code3 2000 1700 25
11/12/2010 C3 P1 Code4 3000 1600 10
11/11/2009 C2 P2 Code5 5000 3000 30
Grand Total 12000 9000 90
Here we are using Column selector for Date column to change the report from Date to Week (or) Month (or) Quarter (or) Year.
My Questions
1. I want to compare Default Date report with Perious Date, Last month Date and Last Year Date.
2. If I select Month from Column Selector then I want to compare Month report with Last Month, Last year Month or Perious of Last year month.
3. If I select Year from Column Selector then I want to compare Year report with Last year, or Perious of Last year and so on.
Please help me, how can we achive the above task.
Thanks in Advance.
Balaa...Hello,
First you have to define the new measures for last month, last year and so on. You can refer to this link:
http://www.rittmanmead.com/2007/04/obi-ee-time-dimensions-and-time-series-calculations/
After that, what you can do is instead of using a "Column Selector" you should use "View Selector". You can create different views, one for month, other for Year and include them into a "View Selector".
After that you can add it in "Compound Layout".
Regards,
JorgeRS. -
Hello,
I am using VS2010 shell. I have a matrix report where I have a row group by Year. Then I have a column group by Month.
When I run the report, I get 2013 data on top of 2014 data. Now I need to create a variance by year for each month.
So in the example below, I need to create an expression that will pull the variance for Oct 01... subtracting 2013 from 2014 for the months. So I need to Subtract 8,222 - 4290. I have no clue.
Here is what my rdl looks like.
Thank you for your help.Hi Adrian,
If I understand correctly, you want to calculate the difference order between 2013 and 2014 for every month. And there are only two years in the FISCAL_YEAR field.
If in this scenario, we can simply use the following expression to achieve your requirement:
=first(Fields!ORDER.Value)-last(Fields!ORDER.Value)
The following screenshot is for your reference:
If there are any misunderstanding, please elaborate the issue for further investigation.
Regards,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Compare month sales with previous year same month sales
hi all.
we need to compare given month of this year with same month of last year. we need to compare sales quantity and value.
the query is on 0RT_C40 multiprovider. We have tried all options using 0Calmon, calday, fiscal year... but whenever we specify offset, we are not getting data. there is valid data for previous year.
plz let us know what else to do? check with 0RT_C40.
thanks in advance.
regards: gauraveGaurave,
Are you selecting the time period in a selection in columns or rows, or are you selecting the time period in the Filter or Free Characteristic area.
When you make the initial selection of say Period 11.2007 in the Free Characteristic area, and then within a selection but on an offset to derive 11.2006, the fact that you have made your selection of 11.2007 in the Free Char area will restrict the entire query results to this time period.
Both your picks on time should be in selections in the Columns or the Rows.
Regards
Gill -
To compare current year with prior year
Hi
Please can you help me to create proper sql to get the output like same as I attached herewith . it would be appreciate
polachanYou can do it in multiple ways
1.
SELECT COALESCE(t1.Company,t2.Company) AS Company,
COALESCE(t1.Sales2015,0) AS CurrentYearSales,
COALESCE(t2.Sales2014,0) AS PriorYearSales
FROM Sales2015 t1
FULL JOIN Sales2014 t2
On t2.Company = t1.Company
2.
SELECT Company,
MAX(CASE WHEN YearVal = 2015 THEN Sales ELSE 0 END) AS CurrentYearSales,
MAX(CASE WHEN YearVal = 2014 THEN Sales ELSE 0 END) AS PriorYearSales
FROM
SELECT Company,Sales2015 AS Sales,2015 AS YearVal
FROM Sales2015
UNION ALL
SELECT Company,Sales2014 AS Sales,2014
FROM Sales2014
)t
GROUP BY Company
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Compare the current value with the previous value in the same column
Hi all,
I have to include a statement in a query which allows to compare the current value of column A with the previous value of column A (same column). from there, I need to add a condition in order to have the expected result.
Let's take an example to illustrate what I want to achieve:
I have the following columns in table called 'Charges':
Ship_id batch_nr Order_nr Price
SID1111 9997 MD5551 50
SID1111 9998 MD5552 50
SID1111 9999 MD5553 50
SID2222 8887 MD6661 80
SID2222 8887 MD6662 80
SID2222 8887 MD6662 80
SID3333 6666 MD7771 90
I want to check if the ship_id of row 2,3 (and more if available) is equal to the ship_id of row 1.
If it is the case, then value 'together with the first batch_nr' in row 2 and 3 under Price column. If not, then keep the original value of Price column
PLease see below the expected result:
Ship_id batch_nr Order_nr Price
SID1111 9997 MD5551 50
SID1111 9998 MD5552 together with 9997
SID1111 9999 MD5553 together with 9997
SID2222 8887 MD6661 80
SID2222 8887 MD6662 together with 8887
SID2222 8887 MD6663 together with 8887
SID3333 6666 MD7771 90
Thanks in advance for your help, it is really urgent.
Imco20030Hi,
user11961002 wrote:
Hi,
Here is the query that I use:
[ select
sl.ship_id,
o.ordnum,
o.reffld_5 "BatchNR",
sum(tc1.chrg_amt) "FreightPRC",
sum(tc2.chrg_amt) "FuelPRC",
sum (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt) "Total Price"
from ord_line ol
join ord o on (ol.ordnum = o.ordnum and ol.client_id = o.client_id)
join shipment_line sl on (ol.ordnum = sl.ordnum and ol.client_id = sl.client_id and ol.ordlin = sl.ordlin)
join adrmst a2 on (o.rt_adr_id = a2.adr_id)
left join tm_chrg tc1 on (tc1.chargetype = 'FREIGHT' and tc1.chrg_role = 'PRICE' and tc1.ship_id = sl.ship_id)
left join tm_chrg tc2 on (tc2.chargetype = 'FUELSURCHARGE'and tc2.chrg_role = 'PRICE' and tc2.ship_id = sl.ship_id)
where sl.ship_id = 'SID0132408'
group by o.client_id, o.ordnum, o.reffld_2, sl.ship_id, a2.adrnam, a2.adrln1, a2.adrpsz, a2.adrcty, a2.ctry_name,
o.reffld_5, ol.early_shpdte
order by ship_id
]That looks like the query you were using before you started this thread.
Modify it, using the analytic fucntions FIRST_VALUE and LAG, like I showed you.
I see that you did simplify the problem quite a bit, and it's good that you did that.
It doesn't matter that your real problem involves joins or GROUP BY. Analytic functions are calculated on the results after all joins and GROUPS BYs are done. Just substitute your real expressions for the simplified ones.
For example, in your simplified problem, there was a column called order_nr, but I see now that's it's really called o.ordnum. Where the solution I posted earlier says "ORDER BY order_nr", you should say "ORDER BY o.ordnum".
Here's a less obvious example: in your simplifed problem, there was a column called price, but I see now that it's really SUM (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt). Where the solution I posted earlier says "TO_CHAR (price)", you should say "TO_CHAR (SUM (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt))". (You can't use an alias, like "Total Price", in the same SELECT clasue where it is defined.)
I removed some columns from the select as they are not relevant for the wanted action like 'adress details or other references'.
Now here is the result:
Shipment ID Order Number WMS Batch Freight Fuel Price Order Total Price
SID0132408 MDK-000014-05602649 04641401 110 10 120
SID0132408 MDK-000014-05602651 04641402 110 10 120
SID0132408 MDK-000014-05602652 04641363 110 10 120
as you can see, the 3 orders have the same shipment ID.
The expected result should be shown under column 'Total Price' as follows:
Shipment ID Order Number WMS Batch Freight Fuel Price Order Total Price
SID0132408 MDK-000014-05602649 04641401 110 10 120
SID0132408 MDK-000014-05602651 04641402 110 10 tog with 04641401
SID0132408 MDK-000014-05602652 04641363 110 10 tog with 04641401Okay, so those are the correct results that I asked for, plus the incorrect results you're getting now. Thanks; extra information doesn't hurt.
But where is the raw data that you're starting with?
It looks like you tried to format the code (but not the results) by typing this 1 character:
before the formatted section and this different character
after the formatted section. To post formatted text on this site, type these 6 characters
before the formatted section, and the exact same 6 characters again after the formatted section. -
Compare previous with Current Value
Want to compare previous with current value and assign the right one..
COLA COLB
72 21356
41023 21356
90 78903
90 89078
90 78956
90 45632
41023 78903
41023 45632
Output I want is:
COLA COLB
72 21356
72 21356
90 78903
90 89078
90 78956
90 45632
90 78903
90 45632
Anytime the value in COLA is 41023, I need to look at value in COLB and compare it with the rest of values and assign the COLA value that is NOT 41023
Thanks...Not sure but here a try :
SQL> select * from tbltbl;
COLA COLB
72 21356
41023 21356
90 78903
90 89078
90 78956
90 45632
41023 78903
41023 45632
8 rows selected.
SQL> MERGE INTO tbltbl a
2 USING (select c.cola,b.rowid rwd
3 from tbltbl b,
4 tbltbl c
5 where b.cola=41023
6 and b.colb=c.colb
7 and c.cola!=41023) d
8 on (a.rowid=d.rwd)
9 WHEN MATCHED THEN UPDATE set a.cola=d.cola;
3 rows merged.
SQL>
SQL> select * from tbltbl;
COLA COLB
72 21356
72 21356
90 78903
90 89078
90 78956
90 45632
90 78903
90 45632
8 rows selected.Works only if colb is unique for non 41023 value.
Nicolas.
Oh, very very late.
Edited by: N. Gasparotto on Oct 3, 2008 5:05 PM -
Comparing the current value with the previous one in Powershell
Hi,
New to scripting and i was wondering how can I compare the current value with the previous value?
I am having trouble with the loop structure, and I am not sure I am on the right track...
I am trying to compare the record to next record in the same csv file after import-csv... My code runs fine, but is not giving the right result.
$FilePath = Get-FileName -initialDirectory "C:\"
#Testing for null
If($FilePath)
$Data = Import-csv -Path $FilePath | Sort-Object BUYER, {[int] $_.PO_NBR}, {[int] $_.LINE_NBR}
Foreach($fData in $Data)
$i = $fData
Foreach($i in $fData)
if($fData.Buyer -eq $i.Buyer)
#save all the same buyer name to a new variable
Write-Host "Same as previous"
Else
Write-Host "Variable is null"
Remove-Item function:\Get-FileNameThank you. The Foreach loop is now working properly.
Can I ask what is the purpose of "-ea 0" in the import-csv? I can't seem to find "-ea" as a parameter for import-csv in help.
-ea is short for -ErrorAction.
Don't retire TechNet! -
(Don't give up yet - 13,225+ strong and growing) -
Compare few columns current value with previous version within a table
I have a table that stores version information. Everytime there is a change in one field, a new version is created. I need to get the last value and the current value (after the update). There might be around 12 columns that I need to check for any updates.
How may I achieve this?
Any help greatly appreciated.
Thx!Perhaps you're looking for something like
SELECT col1, col2, col3, ... colN
FROM (
SELECT col1, col2, col3, ... , colN, RANK() OVER (ORDER BY update_date DESC) rnk
FROM your_table
WHERE rnk <= 2It would be very helpful in general, if you could provide DDL
SCOTT @ jcave102 Local> create table a (
2 version number,
3 create_time timestamp,
4 col1 number,
5 col2 number,
6 col3 number
7 );
Table created.
Elapsed: 00:00:00.06scripts to insert the data
SCOTT @ jcave102 Local> insert into a values( 1, systimestamp - interval '3' hour, 10, 10, 10 );
1 row created.
Elapsed: 00:00:00.04
SCOTT @ jcave102 Local> insert into a values( 2, systimestamp - interval '2' hour, 10, 9, 9 );
1 row created.
Elapsed: 00:00:00.01
SCOTT @ jcave102 Local> insert into a values( 3, systimestamp, 8, 9, 9 );
1 row created.
Elapsed: 00:00:00.01
SCOTT @ jcave102 Local> commit;
Commit complete.
Elapsed: 00:00:00.00And a description of exactly what you want the results to look like given that data,
VERSION COL1 COL2 COL3
3 8 9 9
2 10 9 9If we have those things, it's relatively easy for us to follow exactly what question you're asking and to write a query that generates the expected output, i.e.
1 select version, col1, col2, col3
2 from( select version, col1, col2, col3, rank() over (order by create_time desc) rnk
3 from a )
4* where rnk <= 2
SCOTT @ jcave102 Local> /
VERSION COL1 COL2 COL3
3 8 9 9
2 10 9 9
Elapsed: 00:00:00.01Otherwise, we have to guess at exactly what you're trying to get and we'll almost always guess incorrectly a couple of times.
Justin -
Create a new column in a table that compares the value of one column with its previous value
The DDL:
DECLARE
@T TABLE
IDNO
int,
name
varchar(40),
[Date]
datetime2,
Price1
float,
Price2
float
DECLARE
@K TABLE
IDNO
int,
name
varchar(40),
[Date]
datetime2,
Price1
float,
Price2
float
INSERT
INTO @T
VALUES(22,'C_V_Harris','2014-01-02 10:23:49.0000000',
23.335,
23.347)
INSERT
INTO @T
VALUES(21,'C_V_Harris','2014-01-02 10:05:13.0000000',
23.357,
23.369)
INSERT
INTO @T
VALUES(20,'C_V_Harris','2014-01-02 09:56:15.0000000',
23.364,
23.377)
INSERT
INTO @T
VALUES(19,'C_V_Harris','2014-01-02 09:45:26.0000000',
23.351,
23.367)
INSERT
INTO @T
VALUES(18,'C_V_Harris','2014-01-02 09:43:20.0000000',
23.380,
23.396)
INSERT
INTO @T
VALUES(17,'C_V_Harris','2014-01-02 09:34:28.0000000',
23.455,
23.468)
INSERT
INTO @T
VALUES(16,'C_V_Harris','2014-01-02 09:30:37.0000000',
23.474,
23.486)
INSERT
INTO @T
VALUES(15,'C_V_Harris','2014-01-02 09:18:12.0000000',
23.419,
23.431)
INSERT
INTO @T
VALUES(14,'C_V_Harris','2014-01-02 09:16:06.0000000',
23.360,
23.374)
INSERT
INTO @K
SELECT
ROW_NUMBER()
OVER (ORDER
by IDNO)
AS RN,*
FROM
@T
SELECT
* FROM
@K
--not working:
SELECT
a.RN,a.Price2
FROM
@K a
INNER
JOIN @K
b
ON
a.RN=b.RN-1
WHERE
a.Price2>b.Price2
I need to create a view with a column (say 'Comp' below) that compares the value of each row in Price2 with the previous Price2 row, and it is greater then +1, the
same 0, and less -1.
The processed table should be:
IDNO
name
Date
Price1
Price2
Comp
22
C_V_Harris
1/2/2014 10:23:49
23.335
23.347
0
21
C_V_Harris
1/2/2014 10:05:13
23.357
23.369
1
20
C_V_Harris
1/2/2014 9:56:15
23.364
23.377
1
19
C_V_Harris
1/2/2014 9:45:26
23.351
23.367
-1
18
C_V_Harris
1/2/2014 9:43:20
23.38
23.396
1
17
C_V_Harris
1/2/2014 9:34:28
23.455
23.468
1
16
C_V_Harris
1/2/2014 9:30:37
23.474
23.486
1
15
C_V_Harris
1/2/2014 9:18:12
23.419
23.431
-1
14
C_V_Harris
1/2/2014 9:16:06
23.36
23.374
-1
How can I structure the statement to get (the most recent - order by date ) result for Comp?Satheesh Variath, I just had to make some corrections from your script to get the correct answer:
CREATE
VIEW vw_Comp
AS
SELECT
TOP 1 t.IDNO,t.name,t.[Date],t.Price1,t.Price2,
CASE
WHEN t.Price2
> LAG(Price2,1)
OVER (PARTITION
BY name
ORDER BY IDNO)
THEN 1
WHEN t.Price2
< LAG(Price2,1)
OVER (PARTITION
BY name
ORDER BY IDNo)
THEN -1
ELSE 0
END
AS Comp
FROM
@T t
ORDER
BY DATE
DESC
The adjustments: the selection of the most recent comparison (Top 1) and the use of the function LAG (instead of LEAD) to get the previous value of the column.
Maybe you are looking for
-
Hello All, Can anybody please help me to create a dropdown for various roles in the portal,so that if the user clicks on the first role in the Top Level Navigation ,he should see a dropdown list with other roles being displayed and listed to be selec
-
hi 1 - the standard is calling task 50000075 EXTSRV PROCESS to call the approval form. its shown in display mode 2 - im trying to call ISR_CALL_FOR_CHANGE so the form should open in edit mode but...... my problem is though it opens in edit more, appr
-
Hello, I need to use EDI and IDOCs to transfer a purchase order directly from my ECC system to a business partner's system. I'm new to IDOCs, so I've been having some dificulties to customize the whole scenario. Do you know if there is guide I can fo
-
When I print a color in Photoshop, it looks perfect. The entire doc needs to be printed in InDesign. When I print from Indesign, the colors look wrong. Color setting are synchronized throughout CS6. I have set the profile for the paper and printer I
-
Hi If we got Nexus 1000V from VMWARE , can we add the N1K to our CCO ( Cisco Account ) to have direct support from Cisco as sometimes it take some more time to get answer from VMWARE -> Cisco Thanks