Calculate difference based on 1 dimension
Hi guys,
I have 1 measure SALES and 1 dimension TIME. How can I calculate the difference in sales between for example month July and August?
Kind regards,
Dietrich
Try below
First extract Month from Time dimension and crate it as measure.then create object with formulae and see it f it works
=SALES Where([Month]=[Month])-SALES Where([Month]=[Month]-1).
I am not sure if it works.Pls try yourself
Similar Messages
-
Calculate difference based on values from 2 different columns
Hello friends,
I want to basically do something like below which is in T-SQL Format :
SUM(CASE columnA WHEN 'ABC' THEN 1 ELSE 0 END) - SUM(CASE columnB WHEN 'XYZ' THEN 1 ELSE 0 END)
For which I was changing the code to following in Oracle :
SUM(CASE columnA='ABC' THEN 1 ELSE 0 END) - SUM(CASE columnB='XYZ' THEN 1 ELSE 0 END)
But its failing validation with an error message - missing right paranthesis....
Rest of the qry is fine and whenever I add this line it starts failing.
Edited by: Sweta on 11-Sep-2009 09:32Try this
SUM (CASE
WHEN columna = 'ABC'
THEN 1
ELSE 0
END)
- SUM (CASE
WHEN columnb = 'XYZ'
THEN 1
ELSE 0
END)or
COUNT (CASE
WHEN columna = 'ABC'
THEN 1
END)
- COUNT (CASE
WHEN columnb = 'XYZ'
THEN 1
END)Remark : you can use this sythax in oracle
SUM(CASE columnA WHEN 'ABC' THEN 1 ELSE 0 END) - SUM(CASE columnB WHEN 'XYZ' THEN 1 ELSE 0 END)Example
SELECT emp_test.*,CASE ename
WHEN 'SCOTT'
THEN 1
END ind
FROM emp_test
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO IND
7369 SMITH CLERK 7902 1980-12-17 800 20
7499 ALLEN SALESMAN 7698 1981-02-20 1600 300 30
7521 WARD SALESMAN 7698 1981-02-22 1250 500 30
7566 JONES MANAGER 7839 1981-04-02 2975 20
7654 MARTIN SALESMAN 7698 1981-09-28 1250 1400 30
7698 BLAKE MANAGER 7839 1981-05-01 2850 30
7782 CLARK MANAGER 7839 1981-06-09 2450 10
7788 SCOTT ANALYST 7566 1987-04-19 3000 20 1
7839 KING PRESIDENT 1981-11-17 5000 0 10
7844 TURNER SALESMAN 7698 1981-09-08 1500 30
7876 ADAMS CLERK 7788 1987-05-23 1100 20
7900 JAMES CLERK 7698 1981-12-03 950 30
7902 FORD ANALYST 7566 1981-12-03 3000 20
7934 MILLER CLERK 7782 1982-01-23 1300 10
14 rows selected. -
How to calculate difference and percentage in matrix report dynamic columns in SSRS 2008
Hi Friends,
I need to calculate Difference and Percentage In matrix report SSRS 2008
1) Row grouping based On Product
2) Column Grouping Week and Fiscal Year Current week and Previous Year same Weeks
3)Data Invnetory(Value fileld)
Example:
If value1 and Value2 Available we need to calculate Percentage and Difference.Otherwise Not required NA I need to Show.
For example If Particular week,Current year data is available,Previous year week data is not available No
need to cal Diff and Percentage we need to show Empty.
Below Code is working for If two values is available.
If any one of the fiscal year week data is not there it's taking some garbage values.
I tries with If condition in GetPCT() and GetDiff() It's not working.
Can some one please help me on this.
I am using the custom code
Public Shared Value1 as String
Public Shared Value2 as String
Public Shared previous as string
Public Shared previousweek as string
Public Shared Function GetValue(Value as String,partner as String,Week as String) as String
If partner =previous and Week =previousweek Then
Value2=Value
Else
previous=partner
previousweek=Week
Value1=Value
End If
return Value
End Function
Public Shared Function GetDiff()
return Value2-Value1
End Function
Public Shared Function GetPct()
return (Value2-Value1)/Value1
End Function
How to handle this.
Thank You, Manasa.VHi veerapaneni,
According to your description, if one of the fiscal year week doesn’t have data, the custom code returns false results.
For your requirement, if NULL value exists in the database, we should replace it as zero then perform calculate. So within the code, we should judge whether the value is NULL. To achieve your goal, please refer to the steps below:
1. Create a table like below.
create table dif4
([Product Group] varchar(50),
[Week] varchar(50),
[Fiscalyearweek] varchar(50),
value int
insert into dif4 values
('Desktops','W01','FY14W01',0),
('Desktops','W01','FY15W01',45),
('Desktops','W02','FY14W02',null),
('Desktops','W02','FY15W02',30),
('Desktops','W03','FY14W03',12),
('Desktops','W03','FY15W03',50),
('Notebooks','W01','FY14W01',35),
('Notebooks','W01','FY15W01',56),
('Notebooks','W02','FY14W02',45),
('Notebooks','W02','FY15W02',87),
('Notebooks','W03','FY14W03',75),
('Notebooks','W03','FY15W03',105),
('Tablets','W01','FY14W01',34),
('Tablets','W01','FY15W01',46),
('Tablets','W02','FY14W02',49),
('Tablets','W02','FY15W02',96),
('Tablets','W03','FY14W03',42),
('Tablets','W03','FY15W03',113)
2. Add the custom code in the Report Properties.
Public Shared Value1 as Integer
Public Shared Value2 as Integer
Public Shared previous as string
Public Shared previousweek as string
Public Shared Function GetValue(Value as Integer,product as String,Week as String) as Integer
If Value=Nothing Then
Value=0
End If
If product =previous and Week =previousweek Then
Value2=Value
Else
previous=product
previousweek=Week
Value1=Value
End If
return Value
End Function
Public Shared Function GetPct()
If Value1=0 Then
return 0
Else
return (Value2-Value1)/Value1
End If
End Function
Public Shared Function GetDiff()
return Value2-Value1
End Function
3. Design the matrix like below.
4. Then get the expected results.<o:p></o:p>
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu
Qiuyun Yu
TechNet Community Support -
Have trouble creating formula using FormCalc that will calculate difference in time (hours and minutes) from a Start Date/Time field and End Date/Time field.
I am using to automatically calculate total time in hours and minutes only of an equipment outage based on a user entered start date and time and end date and time.
For example a user enters start date/time of an equipment outage as 14-Oct-12 08:12 AM and then enters an end date/time of the outage of 15-Oct-12 01:48 PM. I need a return that automatically calculates total time in hours and minutes of the equipment outage.
Thanks ChrisHi,
In JavaScript you could do something like;
var DateTimeRegex = /(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d)/;
var d1 = DateTimeRegex.exec(DateTimeField1.rawValue);
if (d1 !== null)
var fromDate = new Date(d1[1], d1[2]-1, d1[3], d1[4], d1[5]);
var d2 = DateTimeRegex.exec(DateTimeField2.rawValue);
if (d2 !== null)
var toDate = new Date(d2[1], d2[2]-1, d2[3], d2[4], d2[5]);
const millisecondsPerMinute = 1000 * 60;
const millisecondsPerHour = millisecondsPerMinute * 60;
const millisecondsPerDay = millisecondsPerHour * 24;
var interval = toDate.getTime() - fromDate.getTime();
var days = Math.floor(interval / millisecondsPerDay );
interval = interval - (days * millisecondsPerDay );
var hours = Math.floor(interval / millisecondsPerHour );
interval = interval - (hours * millisecondsPerHour );
var minutes = Math.floor(interval / millisecondsPerMinute );
console.println(days + " days, " + hours + " hours, " + minutes + " minutes");
This assumes that the values in DateTimeField1 and DateTimeField2 are valid, which means the rawValue will be in a format like 2009-03-15T18:15
Regards
Bruce -
CFM /TR - how system calculate amount based on rate FX 60A
Hi all,
i need to know how system calculates amount based on rate entered upon creating a contract (t-code TX01).
steps input:-
1. header - comp code, product type, trans type
2. partner
3. purchase curr & amount (eg. IDR 8,345,545,500)
4. sale currency only (amount system will auto calculate) USD
5. rate field = 11.553
6. spot rate will auto pick up from rate
7. value date
8. contract date
upon TBB1 no error. posting log as follows:-
FX1000+ : 40 8,345,545,500 IDR bank GL acc
50 8,345,545,500 IDR clearing acc
FX2000- : 40 722370.42 USD clearing acc
50 722370.42 USD bank GL acc
but upon TPM18 error occurred as follows:
DBT_C009 - GL not maintain in acc symbol 5.3.4
DBT_E039 - no posting spec assigned to update type
DBT_B018 : 40 0 USD, 431,977,511 IDR gain/loss
50 0 USD, 431,977,511 IDR clearing acc
so, after maintained DBT_C009 as follows still error for DBT_E039:
40 0 USD, 38 IDR clearing acc
50 0 USD, 38 IDR P&L gl acc
what i don't understand is how system calculate and get DBT_C009 & DBTE039.
what is the function of TPM18?
thanks.Hello Prarnod,
I have done the first node only for actuals that come from the integration to the internal order.
I have tried setting up 2 and 3 even though the 3rd one does not make any sense to me
Thanks,
Paul -
Resize intensity image based on pixel dimensions
Hi,
I want to resize an intensity graph to an exact pixel-by-pixel size, but I do not see this option anywhere. Right now I need to create a 257x256 intensity graph on the front panel, but I have no idea how to do this. Does the graph automatically reshape the viewable area based on the dimensions of the 2d array that I provide it?
Thanks,
AnthonyHello,
There is an intensity graph property available called Plot Area: Size which will set the plot area (width and height) in pixels - I think this is exactly what you are looking for. Attached is an example of this in version 7.1, otherwise you can just right click the intensity graph on your block diagram and Create -> Property Node, and then use the operating tool on the property node to select the noted property.
Best Regards,
JLS
Best,
JLS
Sixclear
Attachments:
Programmatically Set Intensity Graph Plot Area in Pixels.vi 24 KB -
Calculate Commissions based on sales
Hello,
is there a way in SAP to calculate commissions based on sales?
We have hired a sales man. Is there a way to implement his company as a account and that he will get a payment check for his comissions once the customers paid the invoices?
I know there are already many threads here about this topic and I browsed through a lot of them. But I still don't have an idea how to set this up. I also checked this link already, but it didn't really help me a lot.
http://www.sap-img.com/sap-sd/steps-to-create-commission-for-agent.htm
Any help?
Thanks a lot
AnneAnne, the commissions are a rather complex subject in SD, probably because companies handle the process differently and also sales reps are usually very sensitive about the subject. There is a special module "Incentives and Commissions" by Vistex, which is designed specifically for this task. It is pretty expensive, from what I've heard.
There is also something called "SAP Compensation Management", but I'm not familiar with it and am somewhat skeptical about the claims made here:
http://sdmodule.com/sap-chargebacks-without-vistex/87
P.S. You write "a sales man", so I'd question if it's worth bothering at all for just one person.
P.P.S. I couldn't help but notice that you have many posts but 0 points. You might want to start contributing to the community, otherwise just don't be surprised if you won't get many answers. -
Hi
I am creating a simple design studion project request form where the user can enter how many photographs need to be ordered. I am calling this field 'NumImages'. Then once the data is entered, another field (I am calling this NumDaysImage) will be calculated based on the fact that no more than 5 photographs can be shot per day. So, 1-5 photos = 1 day. 6-10 photos = 2 days. 11-15 photos = 3 days etc. I do not need to calculate part days, so 6 photos is the same as 10 i.e. 2 days.
Once I have calcuated 'NumDaysImage', I then need to calculate an end date called 'DateDue'. The start date is entered by the user in the field 'DateStart'.
I know this is not going to be easy, but how can I calculate 'DateDue' based on a Mon-Fri working week, and ideally excluding UK public holidays?
Also on the form is a value 'NumDays' that is the number of days for designing the brochure for the photos. This value I have calculated already, but it will need to be added to 'NumDaysImage' to get a total number of production days that is then used to calculate 'DateDue'.
Any help will be greatly appreciated. Thanks.JavaScript has the Math.ceil method which rounds up a number to the next integer if it is not an integer.
Dates are more complicated calculation as the starting date needs to be converted to a number and then one can calculate the ending date and test that date to see if is a Sunday or Saturday. Do intervening weekends add to the number of days for processing. -
How to calculate difference between date in hours?
Hi All.
I need calculate difference between first and last date. I'm using the code below:
int differenceDate = CalendarRule.elapsedDays(fromDate : myFirstDate, toDate : myLastDate);
This code return an result in days. But I need that result was in hours.
Has anybody help me?Interval dif;
dif = myLastDate - myfirstDate;
display((dif.hours));
Hope it helps -
Can We generate Check report based on Custom Dimension in FDM
Hi All,
We got a requirement in our project to generate the check report based on custom dimension. As far as i know the check reports that got generated in FDM are based on Entity Dimension.
So, will you please let me know whether it is possible to generate report based on any one of the custom dimension.
Thanks.I guess I am not understanding the question here?
The check report is based on the location/entity that you are running the report for. You can pull values for a specific intersection in the target application with the check report, so you could specify the custom dim in the intersection. -
Hierarchy based on one dimension.
Hi,
How to create a hierarchy based on one dimension. For example: we have table:
Category
Category_ID
Parent_Category_ID
I want to create hierarchy, which like as:
Category_Level_1
Category_Level_2
Is it possible without create new alias of table for each level?
ThanksWhich version of BO are you using?
Assuming that you are using BO XI R2 or above version.
And Is your question - how to create custom hierarchies in Universe Designer..... for two different fields (columns) taken from a single database table?
If so, yes you can create custom hierachy for above scenario. In Custom Hierarcies option: Add the Parent_Category_ID first and below that add Category_ID.
If you want to rename your hierarchy levels as Category_Level_1 & Category_Level_2, then rename their corresponding objects names in Clasess & Objects pane.
- Anil -
Need Help to calculate difference between times
Hello everyone,
I have two fields which just stores the time in 24 hour format ex: 08:00 and 20:00 now I want to calculate difference between the two times
Kindle help me
Thanks for your help
Thanks
RaviAre your fields of varchar2 datatype or...?
Is 08:00 the start time or 20:00?
Date arithmetic is pretty simple in Oracle if you use the right datatype.
See:
http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551242712657900129
Assuming you are storing strings:
SQL> -- generating sample data:
SQL> with t as (
2 select '08:00' btime, '20:00' etime from dual
3 )
4 --
5 -- actual query:
6 --
7 select numtodsinterval(to_date(etime, 'hh24:mi') - to_date(btime, 'hh24:mi'), 'day') nti
8 , (to_date(etime, 'hh24:mi') - to_date(btime, 'hh24:mi'))*24 dt
9 from t;
NTI DT
+000000000 12:00:00.000000000 12
1 row selected.
SQL> -
Calculate difference between two dates/times
Hi all,
Is there any function module to calculate difference between two dates/times which are in TIMESTAMPL format.
I need to know how many millisconde(second,minutes, hours... )there is between these two times.
Please, It is urgent
Thank you all.
Karimhi,
try the following function
CALL FUNCTION 'CCU_TIMESTAMP_DIFFERENCE'
EXPORTING
timestamp1 = timestamp1
timestamp2 = timestamp2
IMPORTING
difference = diff
EXCEPTIONS
OTHERS = 1.
the above function gives the difference in seconds...
try the following code to set the resolution to milliseconds..
SET RUN TIME CLOCK RESOLUTION LOW
check the thread for details:
SET RUN TIME CLOCK RESOLUTION?
all the best!!!
Regards,
Aparna -
Calculate difference in value based on two date parameters
Hi All,
I have a table and need to calculate the difference in rent amount for a property based on two date parameters.
I have uploaded sample data here:
https://app.box.com/s/pu8oa4f3jhrhm0ylshdz2fuo7541vn4z
Thanks
JagHi jaggy99,
Do you have the knowledge of
Excel Add-In? If you don't have knowledge of C#/VB.NET language and Visual Studio, I don't think Excel Add-In is what you want. As I said previously, your problem is totally about the business logic, we don't provide solution for a complete requirement.
Based on your sample data, I think VBA code is suitable.
If you're not familiar with VBA, please take a look at the MSDN documents for scratch:
Getting Started with VBA in Excel 2010
The steps should be like this:
1. Sort all the records by [Rent Change Date] field
2. Loop throuth the records and find the FromDate and ToDate as well as the corresponding [Rent Charged] field
3. Calculate the difference and save the data into a new range
It's not so hard, please have a try, if you encounter any development problems, you can post in this forum.
Thanks.
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.
Click
HERE to participate the survey. -
Can we calculate difference of dimension properties values in script logic
HI
I have 3 products, whose manufacturing process starting perod and end periods are different for three products. Now I want
to distribute total manufactuing cost to those periods only for each product. how will write script logic for this senario.
My system is BPC nw7.5
MahiHi,
So, you want to find the difference between the dates and distribute the cost among them. I dont think this will be feasible using script logic. My suggestion would be use BADI. Script logic cannot do manipulation on the properties. BADI will be much easier. In addition to this, you need to think what should be the destination of the result. Every record is going to generate few records (depending on the number of months).
Hope this helps.
Maybe you are looking for
-
Problem with typing in illustrator
When ever I hold down the shift key when I am typing in illustrator nothing comes up. It completely ignores every character I try to put in. Lower case works but upper does not. Has anyone heard of this or knows a fix I could use? I am not sure what
-
SRM - Catalog Content Management
Hi SRM Masters Can any one could send me the config documentaion for SRM Catalog Content Management document and functionality(other than SRM260 and SRM270 both I have). and also SUS config documents and functionality. Regards Rajesh
-
Plugging in multiple gaming consuls
I just bought my first big flat panel TV, yeah I know surprising huh a little behind the curve. However I do have 2 gaming systems a Wii and a Xbox 360 and the big CRT I had before I could plug both in at the same time! The Toshiba I just bought has
-
Camera Raw Conversion for Elements 7.0
I am not able to open (Nikon D90 generated) Raw image files using Photoshop Elements 7.0 on my (Windows 7) computer. Please advise how to downlad a conversion tool so that I can access these raw images. Thank you. Dave Legger
-
I'm new to Spry, but not to CSS. I'm having major trouble formatting this menu. I've set up my page with a 3-row centered table for simple positioning (I hate trying to get a pure CSS centered layout). The width is 940px and the horizontal menu is su