Complex rate calculations
A bit of background (especially for anyone not in the UK). Here people are registered with their local doctor's practice. The practices are grouped into consortia. There are several consortia with the city.
I'm looking at hospital referrals. The referrals table has a row for each referral (who, when, what for, etc.), including the practice the person is registered with.
I have a lookup table for practice to consortium.
I also have a table of the practice populations, i.e. the number of people registered with each practice.
What I want is a Disco report for a selected practice, showing the referral rate for the practice and the referral rate for that practice's consortium.
I've set up parameters to select the consortium and practice, and removed the conditions based on those parameters (otherwise I only get the practice data, not the whole consortium, of course).
Then I can use CASE statements to get the total referrals and total population for the practice and the consortium.
Now I need to calculate the rates, but Disco just breaks when I try! It disconnects me.
So for the consortium admissions I've got:
SUM(CASE WHEN Cur open practs cons mv.Consortium name = :Consortium THEN "V opref act 0607 disco".M gp refs ELSE 0 END)
and for the consortium population I've got:
SUM(CASE WHEN Cur open practs cons mv.Consortium name = :Consortium THEN Pbc weighted pops.Prac pop ELSE 0 END)
I want to divide the admissions by the population, but Disco won't have it.
Does anyone have a brilliant solution?
I think the only way out is to create a table or materialised view with the rates precalculated.
If you've read this far - thank you!
Ros
1. What happens if you pre-calculate the value (calc_div) such as:
case when NVL(SUM(Pbc weighted pops.Prac pop),0) = 0 then 0
else
SUM("V opref act 0607 disco".M gp refs) / SUM(Pbc weighted pops.Prac pop)
end
and then check for consortium, such as:
CASE WHEN
Cur open practs cons mv.Consortium name = :Consortium
AND
Cur open practs cons mv.Consortium name = :Consortium
THEN
calc_div
ELSE 0
END
Just wondering if that would be more appetizing to Disco.
2. I trust you're only displaying aggregated data at this point, right (ie: not mixing detail rows of data with these sum calcs)?
Not a "brilliant" solution, but maybe see what happens by breaking it down first.
Russ
Similar Messages
-
Creating a rate calculator [was: how do i create this?]
I want to create a rate calculator on a website with 2 input fields: calling from and calling to. Here is what i've got:
CALLING FROM table:
COUNTRY $/MIN
Africa 0.10
Europe 0.20
Asia 0.30
CALLING TO table:
COUNTRY $/MIN
Africa 0.20
Europe 0.30
Asia 0.50
USA 0.10
Basically to get the rate $/min the CALLING FROM selected country and the CALLING TO selected country will be added together i.e calling from africa to USA would be $0.20/min (0.10 + 0.10).
- How do i create the database for this? (in access)
- How do i then create the rate calculator in a webpage? (asp/php)???
I would really appreciate anyone who will be able to help me in this.
Thank you very much.
Natalie
[Subject line edited by moderator to indicate nature of question]Create a database table with 3 columns
Country
ToRate
FromRate
Populate these values as appropriate.
Create two drop down menus on your page; FromRate and ToRate. Populate these with the values (Display value and rate) from the table.
Then, you could either:
1) Submit the form to a server side script that adds and displays the values
2) Use Javascript to add and display the values -
Exchange Rate calculation not happening for Special GL in FAGL FC_VAL
HI ,
Exhcange rate calculation for all reconciliation accoout going on but for specilal gl not happens.
Could you please tell me whether system calculates or not for special gl or calculates only reconciliation account in FAGL_FC_VALIts going well
-
Complex SQL calculated/Group Query
I am trying to write a complex aggregate query(s) to compile a standings table for a soccer league.
There are four related tables:
Matches
Goals
Players
teams
I have yet to finalize the database structure so I can add fields if necessary.
In the goals table I track the match that the goal was scored in and which player
scored it.
I am trying to create a query that will give me a standings table.
The fields I need to calculate are:
team name
Wins
Loses
Draws
For instance: There was a match on 4/21/2012. The players on HomeTeam(A) scored a combined 6 goals. The players on AwayTeam(B) scored 1 goal (All stored in the Goals table). Therefore, Hometeam won by a score of 6-1. I need
a query that spits out:
Team Wins Losses Draws
Points
HomeTeam(A) 1 0 0
3
AwayTeam(B) 0 1 0 3
Wins are worth 3 Losses 0 and Draws 1 point each team.
I am a long time SQL admin, but I think the complexity of calculating this is a little beyong me. I need some help to get where I need to be.Okay, I haven't yet been able to figure out the draws because of the trouble of linking back to both teams, but here's what I have so far.
First, here is the test data:
Declare @tvMatches Table (
MatchID int IDENTITY(1,1)
,MatchDate datetime
,HomeTeamID int
,AwayTeamID int
Declare @tvGoals Table (
GoalID int IDENTITY(1,1)
,MatchID int
,PlayerID int
,TeamID int
Declare @tvPlayers Table (
PlayerID int IDENTITY(1,1)
,TeamID int
,PlayerName varchar(30)
Declare @tvTeams Table (
TeamID int IDENTITY(1,1)
,TeamName varchar(20)
Insert @tvTeams
Select 'Winners'
Union All
Select 'Losers'
Union All
Select 'Friars'
Union All
Select 'Planes'
Insert @tvPlayers
Select 1, 'Bill'
Union All
Select 1, 'Jim'
Union All
Select 1, 'Ken'
Union All
Select 2, 'James'
Union All
Select 2, 'Smithy'
Union All
Select 2, 'Flip'
Union All
Select 3, 'Dave'
Union All
Select 3, 'Alan'
Union All
Select 3, 'Ethan'
Union All
Select 4, 'Naomi'
Union All
Select 4, 'Erland'
Union All
Select 4, 'Alejandro'
Insert @tvMatches
Select '20120101', 1, 2
Union All
Select '20120201', 3, 4
Union All
Select '20120301', 4, 1
--Winners beat Losers 3-2
--Planes beat Friars 4-2
--Winners beat Planes 2-1
Insert @tvGoals --Match, Player, Team
Select 1, 1, 1
Union All
Select 1, 3, 1
Union All
Select 1, 5, 2
Union All
Select 1, 6, 2
Union All
Select 1, 2, 1
Union All
Select 2, 7, 3
Union All
Select 2, 8, 3
Union All
Select 2, 10, 4
Union All
Select 2, 11, 4
Union All
Select 2, 12, 4
Union All
Select 2, 11, 4
Union All
Select 3, 1, 1
Union All
Select 3, 3, 1
Union All
Select 3, 11, 4
Using this test data, you want to compile the actual match outcomes. This can be problematic to do on the fly every time though, if you have a lot of matches or teams to calculate for. But, with a simple cte, we have:
;with cteMatches as
Select m.MatchID
,m.MatchDate
,m.HomeTeamID
,ht.TeamName HomeTeamName
,m.AwayTeamID
,at.TeamName AwayTeamName
,( Select Count(1)
From @tvGoals g
Where g.MatchID = m.MatchID
And g.TeamID = m.HomeTeamID
) HomeScore
,( Select Count(1)
From @tvGoals g
Where g.MatchID = m.MatchID
And g.TeamID = m.AwayTeamID
) AwayScore
From @tvMatches m
join @tvTeams ht
on m.HomeTeamID = ht.TeamID
join @tvTeams at
on m.AwayTeamID = at.TeamID
) --select * from cteMatches
This returns the MatchID, MatchDate, team information and the score. Basically, you have the match, team and player data tied to the goals table, so you just do a count (using correlated subqueries) to get the score of each team. Next step is
to calculate the winner and loser (and eventually whether there even was a winner) by comparing the scores:
,cteWinners as
Select cm.MatchID
,cm.HomeTeamID
,cm.HomeTeamName
,cm.AwayTeamID
,cm.AwayTeamName
,Case
When cm.HomeScore > cm.AwayScore Then cm.HomeTeamID
When cm.HomeScore < cm.AwayScore Then cm.AwayTeamID
Else 0
End WinningTeamID
,Case
When cm.HomeScore > cm.AwayScore Then cm.AwayTeamID
When cm.HomeScore < cm.AwayScore Then cm.HomeTeamID
Else 0
End LosingTeamID
From cteMatches cm
) --select * from ctewinners
This returns MatchID, team information and the ID's for winning and losing teams. For now it returns 0 if it's a draw. Once we know the outcomes of all the matches, we calculate the actual win/loss for each team:
,cteRecords as
Select t.TeamName
,Count( Case
When cw.WinningTeamID = t.TeamID Then 1
End
) Wins
,Count( Case
When cw.LosingTeamID = t.TeamID Then 1
End
) Losses
From @tvTeams t
join cteWinners cw
on t.TeamID = cw.HomeTeamID
or t.TeamID = cw.AwayTeamID
Group By t.TeamName
) --select * from cteRecords
That last cte returns just team name, and then the number of wins and losses for each team. This is where I got stuck with the draws, because I'm not quite sure yet how to properly assign a draw to both teams involved.
Now, finally you put it all together with some simple match to determine the points, and there you are:
Select TeamName
,Wins
,Losses
,(Wins * 3) Points
From cteRecords -
How is Opportunity Win Rate calculated
Metrics are not always so easy to figure out.
So is there a list / document that explains how these fields are calculated?
Specifiically how is the Opportunity Win Rate calculated?
Thanks.Win Rate = ((# of wins) / (# of wins + # of losses))
I believe Win = Closed/Won and Lose = Closed/Lost
Refer Doc ID 565203.1 in metalink for more details. -
ACTUAL ACTIVITY RATE CALCULATION
Hi Gurus,
Is it possible to calaculate actual activity rate based on plan hours......
I know that we can splitt the actual cost based on plan hours by selecting splitting rule 22...
Now im doing actul activity rate calculation through ksii...
Then system considering actul hours confirmed in production for actual activity calculation.....
Pls suggest me.
RAMThank you for prompt reply.
Suppose this month we have produced only . 10 finished products.... But actual capacity is 20..... What ever cost moniterd by the production cost centers will be loaded on total 10 products only at the time of revaluation of production orders if we calaculate actul activity rate based on actual hours....... so the cost of the product is getting increased... so that he want to calculate actual rate aslo with planned hours..... Is there any other solution for this..
Pls suggest me ...... its very urgent.
Ram -
Exchange Rate calculation mismatch in Sales Order Invoice and Cancelled Invoice
Hi,
In Sales Invoice, Exchange Rate is maintained as 7.75132
Invoice Amount is 72000 USD. So the Amount calculated should be 558095.04.
But in Accounting Document the Amount is posted as 558095.15 for the GL Sales Account.
In Cancelled Sales Invoice, Amount posted is 558095.04 in GL Sales Account which is correct.
Please help me understand why there is difference in both the Amount even when the Exchange Rate is same.
Regards,
Debashri DuttaHi Ankur,
Thanks for your reply.But our problem is sales order,exchange rates are defined with M type in OB08 as u have said.However when the periods are different for order entry and invoice generation we are facing the following problem.Orders are at old exchange rates and excise invoice is getting generated at current exchange rate.This is resulting in value difference between commercial invoice and excise invoice.
Please help.
Regards,
Praveen -
Exchange Rate Calculation - Can I change it?
BPCu2019s conversion process is different from the way weu2019re currently operating. Currently, weu2019re pulling data from Oanda.COM for every Currency-to-Currency permutation and using Oandau2019s rounded to 5 decimal place rate to calculate the exchange rates in our Financial System.
However, BPC seems to convert differently. In BPC, we've loaded all Rates to the tblFactRate table as they relate to USD. So, if calculations need to be done between non-USD currencies, the rates are calculated on the fly based on the ratesu2019 relation to the USD rate.
Example:
For February 2010 we have the following Average rates:
Oanda.com (These are the rounded to 5 Decimal rates for the 28 days of February, averaged, then rounded to 5 Decimal Places again)
GBP u2013 USD: 1.56285
EUR u2013 USD: 1.36842
GBP u2013 EUR: 1.14235
In BPC we only have the following rates in the tblFactRate table, so the system cannot use the GBP u2013 EUR rate from Oanda.com. We only load the following:
GBP u2013 USD: 1.56285
EUR u2013 USD: 1.36842
If a conversion is needed for GBP u2013 EUR, it will calculate the rate on the fly as so:
1.56285 / 1.36842 = 1.142083571
So, because Oanda is using a Rounded Average, based on Rounded rates, the way things are now, the BPC Calculated Rate will not match the rates in our Financial System.
Is this a configuration issue or is this simply the way the software does FX Translation? Is it possible to load GBP - EUR rates somehow and have BPC calculate those rates based on what we input rather than the calculation being used?
Thanks!
SeanHi,
I dont think this can be changed. BPC stores the conversion rates with respect to the group currency (or the currency of the parent entity). So, the currency translation is also done based on the group currency, as you have indicated. With 5 places of decimal, the figures will definitely not match.
Hope this helps. -
Hello Experts
I have a Tax combination BED+VAT contains the following tax codes
BED = 16%
E Cess = 2% (on BED)
HS Cess = 1% (on BED)
VAT = 4% (on (BEDE CessHS cess) )
when manually calculated the total tax percentage is 21.1392%
where as in B1 under the tax code it shows Tax Rate as 23 % (1621+4)
Is there any possible way to get the correct Tax Rate in Business One 8.8 .
Regards
ArunHi Arun,
Set formulation as follow -
1. Create Formula for BED -
BED_BaseAmt = Total
BED_TaxAmt=BED_BaseAmt*BED_Rate
2. Create Formula for eCess -
Cess_BaseAmt=BED_TaxAmt
Cess_TaxAmt=Cess_BaseAmt*Cess_Rate
3. Create Create for formula for ShCess-
Shcess_TaxAmt=BED_TaxAmt*Shcess_Rate
Shcess_BaseAmt=Shcess_TaxAmt
4. Create Vat Formula for Vat -
BaseAmt=TotalBED_TaxAmtCess_TaxAmt+Shcess_TaxAmt
TaxAmt=BaseAmt*Rate
5. Create Tax Combination as BED+VAT4 - select tax types BED,eCess ,ShCess and vat then select formula codes as above you defined accordingly.
Thanks
Sachin -
Exhange rate calculations in SAPScript
Hi,
I am trying to calculate the total invoice amount for different currencies in a SAPScript. I am running into a couple of problems.
1: I cannot seem to find the exchange rate ( KURRF ) in KOMK/VBDKA or VBDKR, do you know where else the exhange rate would be populated?
2: I cannot seem to use the commands: /: DEFINE &my_variable&
/: &my_variable& = &KOMK-FKWRT& * &KOMK-KURRF& (pretend KURRF is populated)
is it even possible to do that sort of calculations in SAPScripts? if not, what is an easy way to accompolish this?
I only need to calculate this once.
thank you.u can use FM to get the value in print program..and pass them to the sap script...
The conversion rate is stored in TCURR table...
CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
EXPORTING
date = <fs_komv>-kdatu "<<date of convertion
foreign_currency = komk-waerk
local_amount = wa_komp_o-netwr "<<value to convert
local_currency = <fs_komv>-waers
IMPORTING
foreign_amount = <fs_komv>-kwert "<<Converted value
EXCEPTIONS
no_rate_found = 1
overflow = 2
no_factors_found = 3
no_spread_found = 4
derived_2_times = 5
OTHERS = 6. -
Exchange Rate calculation - Performance problem
Background: I have a fact table with transactional data from a sales system which contains values in different currencies. I have only one reference currency in the reports. The user wants to be able to view the values in the reference currency
but with the exchange rate of the selected date.
I have a table with a row per currency/date combination and the exchange rate to the reference currency.
Records in the fact table also have a reference to the currency and a date.
Initial approach:
I created 2 measure groups, one base on the transactional data from the fact table and one with the exchange rates.
Both measure groups have in common the currency and date dimensions. A many to many relationship makes no sense because I have only one reference currency.
I create a calculated member to aggregate the data up to a selected date, something like this:
with member [Measures].[Net Sales Local Currency] AS (
Aggregate({null:[Time Hierarchy].[Date].CurrentMenber}, [Measures].[Net Sales LC])
member [Measures].[Exchange Rate to Reference] AS (
([Time Hierarchy].[Date].CurrentMenber, [Measures].[Exchange Rate])
member [Measures].[Net Sales Refence Currency] AS (
SUM([Currencies].[ISO Code].[ISO Code], [Measures].[Net Sales Local Currency]/[Measures].[Exchange Rate to Reference])
Results:
When I select only a date member, let's say the 01.01.2014 I get a result within a second. If a put 2 dates in the select the result takes about 10 minutes. I suppose I am making something wrong in my calculated members that cause this peformance penalty.
Could you please help me to debug my MDX code?
Any comments would be highly appreciated.
Kind Regards,
PaulHi Paul,
For MDX query performance, it is usually caused by the following factors:
Bottlenecks from SSAS Formula engines.
Bottlenecks from SSAS Storage engines.
Bottlenecks from system resources.
I would suggest you take a look at the following article which write by Charles, please see:
How do I troubleshoot the slow MDX query performance?http://social.msdn.microsoft.com/Forums/sqlserver/en-US/f1f57e7b-eced-4009-b635-3ebb1d7fa5b0/how-do-i-troubleshoot-the-slow-mdx-query-performance?forum=sqlanalysisservices
Based on your desription, you ecountered the performance issue after use date dimension to slice data. Does this happened at Client or SSAS Server side? Please elaboarte your scenario with more detail, and show the MDX script.
Furthermore, please take a look at the following article regarding currency Conversion in SSAS 2012:
http://social.technet.microsoft.com/wiki/contents/articles/18672.currency-conversion-in-ssas-2012-multidimensional-tabular.aspx
If you have any feedback on our support, please click
here.
Elvis Long
TechNet Community Support -
Sales order takes Translation date for exchange rate calculation
Hi
I am creating the debit memo request via DP91 with reference to the contract. In the debit memo request pricing date has been set as current date but transaltion date has set the contract transaltion date. Debit Memo request document currency is EURO, local currency is GBP and condtion currency is CHF.
In this scinerio in order exchange rate has been calculated against the transation date insted of pricing date.
Can you please advise why the system behaving like this.
Thanks & regards,
Siva.Mike,
I assumed your question is for an additional local currency for a company code (this can be changed in OB22). For the first local currency, the translation date type in OB22 is always set to 3 (Translation Date) and cannot be changed (hence, greyed out). Following that, in accounting entry transactions (for example FB01), you will see a field (Translation Date) where you can specify a date for which you want the system to fetch exch. rate from the exch. rate table. In your situation, you will have to enter 'document date' there.
PS: The reply above by Ravi applies only to tax items' translation, not for all items. He is basically talking about the indicator that you see in OBY6. -
Hello guys,
I got one new requirement.I donot know what approach should I take for this one.
It is like this.We calculate currency rates e.g, BUDGET RATE CY,BUDGET RATE PY,ACTUAL RATE CY like that in a start routine in dataflow as we donot get them from source systems.In our start routine,we have coding for
ACT CY(Actual current year rate),BUD PY(Budget previous year rate),BUD CY(Budget current year rate),.....but now my user wants to see one new rate....its like he wants to see present months data in previous year same months rate....or any month he choose in present year with previous year same months rate...
he wants to see May 2010 data in May 2009 monthly rate..april 2010 data in april 2009 rate.....in our BW...we have one DSO where all monthly rates are stored for all years...like if we take year 2009..they will have monthly rates also stored in it from januari to december....
How can I write a code that calculates this new rate.....and how can I accomodate this new rate code in existing start routine....
Thanks in advance....Hi,
From my limited undersatnding of the requirement, it appears that the monthly rates (for current & previous years) are already being successfully calculated in the start routine. The requirement you have can be addressed in the frontend build (i.e. in query build).
Hope this helps. -
Interest rate calculation configuration & testing
Dear experts
How to configure & calculate Interest on Banku2019s Balance from SAP. Also to know about provision to change the interest rate in between the period.Hi,
BALANCE INTEREST INDICATOR S
INTERST CALICULATION GLOBAL SETTINGS:
/NOB46 INTEREST INDICATORS
DEFINE NUMBER RANGES FOR INTEREST FORMS
/NOB82 INTEREST ON AREARS CALCULATION
/NOBAA PREPARE ACCOUNT BALANCE
/NOBAC DEFINE INTEREST REFERENCE RATES
/NOB83 ENTER INTEREST VALUES
/NOB81 DEFINE TERM BASED TERMS
INTEREST POSTINGS :
/NOBV1 A/R CALICULATION OF INTEREST AREARS
/NOBV3 A/R BALANCE INTEREST CALICULATION
/NOBV4 A/P BALANCE INTEREST CALICULATION
/NOB84 ASSIGN FORMS FOR INTEREST INDICATORS
/NXK02 ASSIGN INTEREST INDICATOR (CHANGE VENDOR MASTER RECORD)
/NF-02 POST LOAN RECEIPT TO VENDOR
/NF-44 EXECUTION OF INTEREST ACCOUNTING-FA-AP-PERIODIC PROCESSING-
INTEREST CALICULATION BALANCES
/NF-44 POSTING OF INTEREST ACCOUNTING-FA-AP-PERIOD PROCESSING-
CALICULATION (VENDOR) INTEREST CALICULATION-F-44 BALANCE
/NF-24 EXECUTE ITEM INTEREST ACCOUNTING-FA-AR-PERIODIC PROCESSING-
CALCULATION ON CUSTOMER INTEREST CALICULATION-ARREARS INTEREST CALICULATION
/NF-47 EXECUTE ITEM INTEREST CALCULATION ON VENDOR
/NF-26 BALANCE POSTING OF INTEREST CALICULATION CUTOMER
/NF-52 BALANCE POSTING OF INTEREST CALICULATION G/L
Regards,
Kishore K -
Hi Gurus,
Please go through the following PCR with input & output tables and explain the calculation. What to do to get the proposed value.
IT
/092 - Rate: 12.07
WT X000 OT 1.5 rate- Number: 45.00
Z015 3 AMT?0
Z015 3 = NUM?0
Z015 3 = * RTE?0
Z015 3 = * = VALBS?
Z015 3 = * = X GCY Z115*
Z115 * VAKEYALZNR
Z115 * N VWTCL 18
Z115 * N * GCY ZZ15
ZZ15 * WGTYP?
ZZ15 * **** VALBS0
ZZ15 * **** ADDNA *
ZZ15 * **** FILLF N
ZZ15 * **** WGTYP=*
ZZ15 * **** VALBS1
ZZ15 * **** NEXTR A
ZZ15 * **** ADDNA *
ZZ15 * **** FILLF N
ZZ15 * **** WGTYP=*
ZZ15 * **** VALBS2
ZZ15 * **** ADDNA *
OT
WT X000 Rate: 18.11 Number: 45.00 Amt 814.95
Supposed formula here is: 12.07 * 45.00 * 1.5 = 814.725 ( Proposed Value )
Plese explain the above PCR calculation.Hi Remi,
Thank you for your answer.
Q. As for processing of your WT X000, what are it's Valuation Bases in V_512W_B ?
- it is valuated in current wagetype and Valuation basis 092 and rate is 150%.
Q. Have you checked through pe04 what is operation VAKEYALZNR ? Isn't it related to Alternative Payment ?
yes, it is alternative payment.
P.S. : 12.07 x 1.5 = 18.105, which will give 18.11 once it is rounded up.
A: we never used any round up function,
Though we not used the roundup function why it is rounded up. How and where can we remove this roundup.
Thank you for your help.
Rgds
-AADI
Maybe you are looking for
-
I have a report that get customers, I have to call another report to print a pdf letter to send to that customer. In the master report I have the code in the Function AfterReport: srw.run_report('report=XXFACVEN.rdf batch=yes desformat=pdf desname=[e
-
Hello, I have a serious problem with my Photosmart Premium C310 series with the scan(ner). I get a black image with white stripes (or an error 30) when I save my picture or my document on Mavericks (Mac OS X 10.9) installed yesterday. With Moutain Li
-
Mac Pro boot sound on Cinema display
Hey guys, Is it possible to run the Mac pro boot sound on my cinema display instead of the Mac pro's build in speakers? My macbook sounds more agressive than that Mac badboy . thanks! -Sam
-
My iTunes won't open! I uninstall it and re-install! When I try to open it says locked disk?
-
Hi All, when i am trying to create the oracle app adapter in jdeveloper , I am getting the following error. java.lang.nullpointerexception at oracle.tip.tools.ide.adapters.designtime.adapter.apps.iRep.IRepStartPage.buildWSDL(IRepStartPage.java:1508