Questions in topic: "calculations"
https://ask.sqlservercentral.com/questions/topics/single/219.html
The latest questions for the topic "calculations"Calculate to show exact result neither rounded up or down
https://ask.sqlservercentral.com/questions/118754/calculate-to-show-exact-result-neither-rounded-up.html
I need this formula to display the exact result when divided:
SET Order_More_Copies = ((t.HoldCount/ @nNumberOfHolds) - t.ItemCount)
The stored procedure identifies bibliographic titles that may need more items ordered to meet the Holds to copy ratio of 5:1
One of the rows lists 100 items with 694 holds. A calculation (divide holds/@nRatio) determines how many more items need to be ordered to meet that ratio. In this case the result is 138.80 which I then subtract from 100 items to get 38.80. The staff want that decimal displayed so they can make the determination to order the additional copy.
When I use SET Order_More_Copies =CONVERT(DECIMAL(5,1),1.00 * t.HoldCount / @nNumberOfHolds) - t.ItemCount the result is 39
When I use SET Order_More_Copies = ((t.HoldCount/ @nNumberOfHolds) - t.ItemCount) the result is 38
Using the actual numbers gives me the correct value select on line 121: CONVERT(DECIMAL(5,2),1.00 *694/ 5) -10038.80
I need to show the 38.80 so at the end-user’s discretion, they can order that “extra” copy should they wish.
I have searched for examples on how to state in the formula that I need the exact computation, neither rounded up or down.
What might I use.
Thank you.
Jon Lellelid
[1]: /storage/temp/2234-expressing-calculation-result-as-decimal.txtdecimalcalculationscast-convertFri, 13 Mar 2015 20:36:17 GMTjonlellelidHow can i calculate age from three data (YearofBirtday, monthofBirthday and dayOfBirthday)
https://ask.sqlservercentral.com/questions/117622/how-can-i-calculate-age-from-three-data-yearofbirt.html
i have a PROFILE table which has 3 rowas : YearofBirtday, monthofBirthday and dayOfBirthday
how can i calculate the actual age ?
thanks a lot guyscalculationsFri, 23 Jan 2015 10:44:59 GMTbillyboxCalculate computer usage during time window
https://ask.sqlservercentral.com/questions/113108/calculate-computer-usage-during-time-window.html
I need to calculate the number of minutes that customers have utilized a computer during the 2PM to 4PM time slot. Some of the customers have logged on outside of the window. How do I subtract those times from both the LogInDate and LogOutDate columns the Deleted Bookings Table?
I figured out how to filter the window of time using the DATEPART [link text][1]function.
[1]: /storage/temp/1560-library+login+logout+calculation.txtdate-rangecalculationsThu, 26 Jun 2014 20:12:58 GMTjonlellelidMDX Calculated Time
https://ask.sqlservercentral.com/questions/108197/mdx-calculated-time.html
I am very rusty in my MDX skills. But I am trying to create a calclulated time member in the cube so users can review in (ugh excel)
in the calculation of the cube I have a named calc as [4Weeks]
The mdx is [Time].[Week].lag(4)
When i process and view - the calculation only appears as "[Time].[Year - Month - Week Time Calculations]"
The member does not appear until i place a filter on it, and I do not have any results. I've looked in the PACKT publishing MDX Cookbook with no luck and I'll have to admit that the Calandering in SSAS is....well...not exactly the sweet spot of the product!!!ssasmdxtimecalculationsWed, 13 Nov 2013 16:29:39 GMTsiera_gldGroup Calculation in sql
https://ask.sqlservercentral.com/questions/106083/group-calculation-in-sql.html
Respected Geeks,
I am having some issues with a flow as i am new to sql server
i have a table
create table objective
(
csid int not null,
memid tinyint not null,
ObjtId tinyint not null,
ObjNm varchar(50) not null,
Freq tinyint not null,
ObjAmt money not null
)
create table objectiveRslt
(
csid int not null,
memid tinyint not null,
ObjtId tinyint not null,
TtlObj money not null
)
I have to store result for every memid after an event from front end
what would be appropriate action to perform it.
Thanks in advance.
[edited to move code from comments to question]
Full table definitions:
CsObjective
create table csobjective
(
CsId int ,
ObjtId tinyint ,
Memid tinyint ,
ObjName varchar(500) ,
Priority tinyint ,
StartYr smallint ,
EndYr smallint ,
PrstCost money ,
LoanFctr money ,
LoanTrm tinyint ,
AstId smallint ,
AstAmt money ,
Remark varchar(100) ,
Oth varchar(2) )
CSBPObjective
create table csBPobjective
(
CsId int ,
ObjtId tinyint ,
MemId tinyint ,
Priority tinyint ,
ObjName varchar(500) ,
StartYr smallint ,
EndYr smallint ,
PrstCost money ,
LoanFctr money ,
LoanTrm decimal(18, 4) ,
AstTypId smallint ,
AstAmt money ,
Remark varchar(100) ,
RtonInv money ,
Inflid tinyint ,
Yrs2Goal decimal(18, 2) ,
FCGoal money ,
LoanAmt money ,
ReqFund money ,
RetId tinyint ,
Lumpsum money ,
YrlySameInv money ,
YrlyContrSGrth money ,
ValPrvsnMade money ,
NetReqFund money ,
TaxRaOfApplicnt decimal(5, 2) ,
EffRtofRtn decimal(18, 2) ,
)
client saves and updates data in csobjective table
Employee takes an action
that stores data in csbpobjective
so how may i accomplish his task
there is also another table which stores data
of sum of some csbpobjective table
according to csid
composite key is csid+objtid in both tables
i want to write a procedure which will brun when employee will click abutton and pass a value from procedure
procedure is as -
declare
@Yr2Goal decimal(5,2),
@Infla decimal(5,2),
@AstRtnVal decimal(5,2),
@SalGrwth decimal(5,2),
@FCofGoal decimal(18,2),
@ValOfPrvMad decimal(18,2),
@EffRat decimal(12,2),
@LoanAmt decimal(18,2),
@ReqFund decimal(18,2),
@NetReqFund decimal(18,2),
@Lumpsum decimal(18,2),
@YrlyInvwithSalGrwth decimal(18,2),
@MemTax decimal(5,2)=20.00,
@PrVal decimal(18,2)=40000,
@StYr varchar(4)=2004,
@AstAmt decimal(18,2)=26000.36,
@LoanFctr decimal(5,2)=12
--years to goal
SELECT @Yr2Goal=isnull((DATEDIFF(month, convert(smalldatetime, '01/01/'+@StYr),dbo.getdateist(1) )/12),0.00)
--set @Yr2Goal=isnull(cast(cast(datediff(month,dbo.getdateist(0),(SELECT CAST(CAST(2004 AS VARCHAR(4)) +'01'+'01'AS DATETIME))) as decimal(5,2))/12 as decimal(18,2)),0.00)
--Future cost of goal
select @Infla=isnull(RtnVal,0.00) from csbpasmptn where asmptnid=18;
set @FCofGoal=dbo.GetFV(@PrVal,@Yr2Goal,@Infla)
--Effective Return
select @AstRtnVal=isnull(RtnVal,0.00) from csbpasmptn where AssetId=/*Asset*/3;
set @EffRat=(@AstRtnVal*(1-(@MemTax/100)))
--value of Provison Made
set @ValOfPrvMad=dbo.GetFV(@AstAmt,@Yr2Goal,@EffRat)
--Loan Amount
set @LoanAmt=((@FCofGoal-@ValOfPrvMad)*@LoanFctr/100)
--Required Fund
set @ReqFund=@FCofGoal-@LoanAmt
--Net Required Fund
set @NetReqFund=@FCofGoal-@ValOfPrvMad-@LoanAmt
--Lumpsum
set @Lumpsum=dbo.getPV(@NetReqFund,@Yr2Goal,@AstRtnVal)
--Yrly Investment with Salary Growth
select @SalGrwth=isnull(RtnVal,0.00) from csbpasmptn where Asmptnid=17;
--sp_helptext GetPMTwithGrowth(contri,year,cg,r,target)
select @YrlyInvwithSalGrwth= PMTGrowth from dbo.GetPMTwithGrowth(100,@Yr2Goal,@SalGrwth,@AstRtnVal,@NetReqFund)calculationsWed, 04 Sep 2013 14:11:49 GMTbhanupratapsngh9SSRS How do I divide column group totals of two matrices that use different datasets?
https://ask.sqlservercentral.com/questions/104798/ssrs-how-do-i-divide-column-group-totals-of-two-ma.html
I have an SSRS Report that has two matrices with a different dataset in each matrix. I have a total column in each matrix. I want to perform a calculation on the values in the totals columns.
Here is what I want to do:
MatrixA.TotalColumn.Value divided by MatrixB.TotalColumn.Value
So I want to see a column of values showing the calculation between the two.
MatrixA uses a different dataset than MatrixB.
Both MatrixA and MatrixB have the same number of rows and columns.
There is a total column on the column group for each matrices. I want to see a column of values of the division of the total columns.ssrscalculationsmatrixThu, 25 Jul 2013 18:46:51 GMTckmst11need time different calculation
https://ask.sqlservercentral.com/questions/102846/need-time-different-calculation.html
Dear All
I have table that has
name | flightdate| from | to | flight number | booking datetime|
Name1 : 10/10/2013: london| frankfurt| 100| 05/10/2013 10:00pm
Name2 : 10/10/2013: london| frankfurt| 100| 05/10/2013 11:00pm
Name1 : 10/10/2013: london| frankfurt| 100| 02/11/2013 6:00pm
how can i get number of rows that has flown same sector same details with small time differnet between first booking and the second booking.
thank you
HakimisqltimecalculationsMon, 20 May 2013 12:29:02 GMThakimiWhich factors depend upon Backup timing ?
https://ask.sqlservercentral.com/questions/102353/which-factors-depend-upon-backup-timing-.html
Which factors depend upon Backup timing ?
ex-source server/Destination server and bandwidth speed ?
Is there any solution to calculate backup timing ?backupscalculationsFri, 10 May 2013 07:10:32 GMTskbarikSSRS Matrix Report Calculation
https://ask.sqlservercentral.com/questions/100894/ssrs-matrix-report-calculation.html
I have a matrix report and at the end i have two calcs. Avg of 12 months and Sum of 12 months - no big deal... - it's a
so Rolling Month 12, 11, 10, 9 ~1 How can I calculate the most recent month / Average Sales using a matrix report....
The underlying db is using sql 2000
If YRMonth = MaxYearMonth = Then Average/Max(YearMonth)
I've tried =Avg(Fields!Sales.value)/SUM(IIF(Fields!Month.value=MAX(Fields!Month.value),Fields!Sales.value,0)) with no luck.
Thanks...
SSRS 2008 R2ssrscalculationsmatrixMon, 01 Apr 2013 18:44:05 GMTsiera_gldhow to calculate data in sql server row
https://ask.sqlservercentral.com/questions/100366/how-to-calculate-data-in-sql-server-row.html
hi im new in sql server or other database tool..before this, i only using excel,
i've create table using sql server 2008 (in VB WD asp.net)
table lay out is like this,
Id Name Mon Tue Wed Thu Fri TX
Id is the students Id,
Name is students name,
Mon - Fri are days they're attend to school and the data inside this column are X and Y,
X means absent and Y means Attend,
TX is the total of X every week,
what i need to do is, how do i calculate each row of the student that will calculate X every week and put the data inside column TX..is there any formula to do this? thanks..and sorry for my english..im from malaysiacalculationsWed, 20 Mar 2013 16:05:28 GMTrsj74to add columns
https://ask.sqlservercentral.com/questions/98281/to-add-columns.html
id year amount
1 1998 232
2 1998 111
2 1999 222
the new table should like
id 1998_amount 1999_amount
1 232 0
2 111 222calculationsThu, 07 Feb 2013 14:08:18 GMTnvnkmr10Analysis services cube calculated value for conditional count of measures
https://ask.sqlservercentral.com/questions/96452/analysis-services-cube-calculated-value-for-condit.html
Hi,
I'm struggling with trying to create a calculation in my cube. I have an accumulating snapshot fact table with some information including:
**LocationKey** (Foreign key to the location dimension)
**Process Identifier** (unique key to identify the individual process grain)
**Process start date** (Foreign key to date dimension)
**Process Days Overdue** (A column calculated at ETL time for the number of days the individual process is overdue by)
When I build my cube, the measures I get are:
**Process Count** (added automatically by SSAS for the count of all proceses)
**Process Days Overdue**
What I'd like to be able to do is add a calculation for:
**Count of Overdue processes** (i.e. number of processes where 'Days overdue' > 0)
**Count of On Target processes** (i.e. number of processes where 'Days overdue' = 0)
I've had some limited success so far. I've managed to get the counts coming out correctly in relation to the total number of processes, but they fail to calculate correctly when I start slicing the data.
For example:
If I have 100 processes, 10 are overdue and 90 on target at the highest level in my cube I can get the information correctly. i.e.:
**Total Count:** 100
**Overdue:** 10
**OnTarget:** 90
However when I, for example split the data by location instead of getting:
**Total Count (Location A):** 80
**Overdue (Location A) :** 8
**OnTarget (Location A) :**72
**Total Count (Location B) :** 20
**Overdue (Location B) :** 2
**OnTarget (Location B) :** 18
my results are not splitting correctly and I'm getting:
**Total Count(Location A):**80
**Overdue (Location A):**10
**OnTarget (Location A):**90
**Total Count (Location B) :**20
**Overdue (Location B):** 10
**OnTarget (Location B):** 90
Any help would be really appreciated. I'm not sure if I'm just doing something wrong, or if my whole understanding is incorrect and what I'm trying to do is impossible...
ThanksssasmdxcubescalculationsanalysisWed, 05 Dec 2012 11:39:03 GMTspivsteritissum up 2 calculated member into a dimension member, SSAS 2008
https://ask.sqlservercentral.com/questions/90179/sum-up-2-calculated-member-into-a-dimension-member.html
I have a dimension member an ex; ABC, under ABC i created 2 calculated member say ABC1 and ABC2 using calculation tab in cube designer.
using some mdx query, i got values for the 2 calculated members.
But in the browser able to see ABC with no value, under ABC i have values for ABC1 and ABC2, problem is the 2 calculated member
is not summing up value to upper level "ABC"![alt text][1]
i would appreciate your help.
Example Below:
[1]: http://ask.sqlservercentral.com/storage/temp/229-SSAS.pngssasmdxcalculationsFri, 15 Jun 2012 18:13:00 GMTSairampremkumarSQL Comands please help me
https://ask.sqlservercentral.com/questions/89728/sql-comands-please-help-me.html
Helo i have a probleme here from the table **Character** >**PCPoints**i have players that paly o this game and win PCPoints letz say 100 and i want to make a php or a SQL JOB , this PCPoints in Tabel **MEMB_INFO** > **cspoints** but after replace them and te same time to add them
Example
before conversion
**
> PCPoints = 100 and cspoints = 5
**
and after i want to have
**
> Pcpoints = 0 and cspoints =105
**
the formula will be a+b = c and a = 0 where A= PCpoints and b=cspoints and c=a+b
![alt text][1] Character
![alt text][2] MEMB_INFO
![alt text][3]
have try to make this code via the book but is not working i mess up i have made a progres but the PCPoints did not delete after conversion
> Update MEMB_INFO Set cspoints =
> a.cspoints+b.PCPoints FROM Character.b
> iner JOIN MEMB_INFO.a ON
> Character.AccountID=MEMB_INFO.memb___id
> where a=cspoints and b=PCPoints
is verry immportant after the conversion the player have 0 PCPoints , because i dont want them to update the cspoints forever please help
[1]: http://iceimg.com/i/c4/29/0589949170.jpg
[2]: http://iceimg.com/i/7a/73/0974ed69da.jpg
[3]: http://iceimg.com/i/5c/f8/6d85fd47dd.jpgsql-server-2005calculationsSat, 02 Jun 2012 02:42:25 GMTzohanCalculate Start and End Time that are Text
https://ask.sqlservercentral.com/questions/88791/calculate-start-and-end-time-that-are-text.html
The data I get is in text from the DB (74125 for 7:41:25)
I need to take the start and end times and calculate the hh:mm:ss
what is the best approach in SQL Server 2008 R2.
Start End ElapsedTime
70500 71002 00:05:02
Thanks
****UPDATE****
I just noticed the time is not string but it is being stored as int.timecalculationsThu, 26 Apr 2012 22:07:08 GMTjaymz69