Formula for calculating aggregate percentage and percenatge of gender

hi all
i have a sp from which i get result columns  gender,percentage,studentcount,year
my sp is like this..
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[usp_GetState]') AND type in (N'P'))
DROP PROCEDURE usp_GetState
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[usp_GetState]
( @ExamYear Smallint
,@ExamType Nvarchar(10)
AS
BEGIN
SET NOCOUNT ON;
WITH cte_Schools AS
SELECT
[Foreign]= CASE WHEN M.Zone ='F' THEN 'Y' ELSE 'N' END
,CASE WHEN M.Zone ='F' THEN UPPER(C.CountryName) ELSE UPPER(S.StateName) END StateName
,COUNT( DISTINCT M.SchoolCode) Schools
,SUM( M.Nos) Students
FROM rptFinalResultSummaryMaster M
LEFT OUTER JOIN State S ON M.StateCode=S.StateCode AND M.Zone=UPPER(LEFT(S.Zone,1))
LEFT OUTER JOIN Country C ON S.CountryId= C.CountryId
WHERE M.Year=@ExamYear AND M.CourseCode=@ExamType
GROUP BY CASE WHEN M.Zone ='F' THEN 'Y' ELSE 'N' END
,CASE WHEN M.Zone ='F' THEN UPPER(C.CountryName) ELSE UPPER(S.StateName) END
SELECT
SlNo=ROW_NUMBER() OVER(PARTITION BY [Foreign] ORDER BY StateName)
,[Foreign] ,StateName, Schools, Students
, Percentage = (Students/(SELECT SUM(Students)*1.000 FROM cte_Schools))*100
FROM cte_Schools
ORDER BY [Foreign],StateName
END
GO
now..i wrote formula for percentage  and when i connected this sp to my rdl where i took tablixi gave percentage value to gender and total percentage column
                                       gender(column group)                      
total
number   percentage
passcategory         
this is my tablix format
my output looks like
boys     girls                                     
total
number(percentage)
passcategory1  (percenatge)                        21 (40.38)          43 (56.75)          
       64(48.56)          
passcategory2   (percenatge)                       11  (21.15)         10    (13.51)               31(17.33)
passcategory3    (percentage)                       20 (38.46)         21    (28.37)               41(33.41)
total                     (percentage)                     
52(xxx)           74  (xxx)                     136   (100%)
i'm not getting thegender percentage properly for girls and boys total percentage of boys and girls coming correctly but individual percentage is not properly coming...that's because in sp i gave calculation for only total percenatge ..how can i calculate
the individual percentage of girls and boys in single column...so that i can place in gender column in tablix..and i can retrieve individual percentgaes of girls and boys seperately as shown in output..
please reply..its urgent
thanks in advance..
lucky

please reply..its urgent
Here is a tip: if you want to tick off people from helping you, you should absolutely include "urgent" in your post. That's a good way to encourage people to move to the next post. I did see this one earlier today, but did not have the time.
Anyway, I cannot really make out heads or tails of your question. Your output takes about gender, but I cannot see it in the output from the query, which appears to group by "Foreign" and StateName. How does the boys and girls get into the picture?
And for that matter that "totals" column?
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • Setting in BEx formula for calculation of YTD and MAT

    Hi,
    I have to implement 2 formulae in BEx.
    As I am trying to avoide ABAP coding, can anyone please suggest SETTINGS in BEx FORMULA to achieve these below mentioned 2 formulae -
    1 ) Calculate YTD - Average of the sum of the reported quarter values from the start of the year until and including the selected quarter. But, if we enter Quarter 3 and there is no data for quarter 2 then the average should be equal to sum of data for Q1 and Q2 divided by 2 instead of 3 even though user entered Q3.
    2) Calculate MAT - Average of the sum of the reported quarter values for the last 4 quarters. We need to check last 4 quarters. If data is present only for 3 quarters in the last four quarters then the MAT will be data for 3 quarters divided by 3.
    Please suggest BEx formulae settings, if any for the above calculations.
    Thanks a lot.
    Regards,
    Prerna

    Hi
    I am not sure requirement related YTD is possible without customer exits variable
    But regarding your 2nd requirement
    Calculate MAT
    Create four restricted key figures by using offset (0, -1, -2, -3) and restriction characteristic will be quarter.
    Create a calculated key figure "Count of Quaerter". This will consist of "Number of rows" key figure with exception aggr on the Quarter characteristic and aggr will be "Count for all not eq to 0".
    Create a calculated key figure which will be sum of four restricted key figures divided by Count of Quarter.
    Kindly let me know incase further details required
    Best Regards
    Rohit

  • I was wondering why the iPhone 5 has the option for a battery percentage and the iPod touch 5g doesn't? I mean... they are almost both the same thing... just the iPod does not have the phone.

    I was wondering why the iPhone 5 has the option for a battery percentage and the iPod touch 5g doesn't? I mean... they are almost both the same thing... just the iPod does not have the phone.

    One likely reason is the % battery is not that accurate because of the smaller battery capacity in the iPod compared to iPhone and iPad. Users why use a % battery app post that the % reading changes a lot.

  • Pls tell me the exact formula for calculation of Safty Stock with quality example

    Pls tell me the exact formula for calculation of Safty Stock with quality example

    Hi Devendra,
    safety stock is a quantity of stock which should be planned to be in inventory to protect against fluctuations in demand or supply. Therefore it is considered in planning.
    The Product Planning Details screen is mainly a planning screen, giving an overview on the planning situation for a product in a planning area. The projected stock reflects the planning behavior, displaying the shortages relevant for the planning run.
    As the safety stock has to be always in stock, the projected stock takes it into account as an immediate demand. That is why it reduces the projected stock, for example, if the stock on-hand is 0, then the initial planning situation for the product with a safety stock shows a negative projected stock.
    For more information please check the help document “Material Planning Settings “ under section safety stock which explain with pictorial rep.
    hope it help you.
    Regards,
    Suresh

  • Formula for calculating Quarter value in current calendar Year

    Hi All,
    I have a requirement where in i need to display values for Q1 of Current Calendar Year, Q1 of Previous Calendar Year,Variance in Value and % Variance in Value...Similarly for Q2,Q3,Q4.
    We have built the report directly from Bex Query from the SAP tab in Crystal Reports. The formula for Quarter1,Variances etc are defined in Bex Structures and i am unable to get 'em individually here rather i am getting them as a whole in a single object with the structure name. Now is there a way that i can define my own formula in Crystal Reports so that i can get the values for the constraints defined above???
    If yes please give me the syntax or an example formula so that i can work around.
    please Help,
    Thanks & regards,
    R.N

    What fields are you getting?
    or what is the data you are working with is it
    transID, date, value......
    or is it
    Q1, Year1, Value.......

  • Formula for arriving at percentage of increase/decrease

    Does anyone know the formula in Numbers '09 to identify sales increase/decrease percent from one cell or date period compared to another? In Excel it is quite simple, i.e. =(B-A)/A and ENTER. This formula doesn't work in Numbers. I'd like to get deeper into Numbers but this is a stumbling block for me.
    Thanks

    Actually, this is the classic textbook manner in which we are trained to arrive at the value of a sales increase or decrease. If, for example we wish to compare December 2008 sales to December 2007 sales, the formula is =(DEC 08-DEC 07)/DEC 07. Then of course you would format the cell to % function and you're good.
    The glitch in Numbers is, as you noted, one cannot click the (DEC 07) cell at conclusion. Your work-around in which one simply types it in solves the problem. Another poster offered advice but it was somewhat different, and that formula works perfectly but is used for a different purpose. That is a formula that seeks to identify the percentage of value or relationship between two cells, NOT the increase or decrease. THAT formula is =DEC 08/DEC 07.
    Thanks all!

  • Formula For Calculating An Average

    I have the below formula in a group footer (Group Footer #1) that is suppose to calculate the average between the accumlated number of days (i.e. {@Days Taken}) divided by the number of records (i.e. Count (). The value for the number of days is correct and the value for the record count is correct. For some reason the value for the average is not correct.  The average is not re-calculating when there is a new group.  The average is repeated for each group.  Is there anything wrong with this formula ?
    Sum ({@Days Taken})/Count ()

    Lenell,
    You need to tell it to divide the sums per group.
    So;
    Sum ({@Days Taken},)/Count (,)
    Replace with the field that you are grouping on.

  • Microsoft`s definition of 「All Instance」 for calculating average percentage of CPU usage is a mystery for me !!!.

    Hi, I was looking up in the 「How to Auto Scale」 document
      http://azure.microsoft.com/en-us/documentation/articles/cloud-services-how-to-scale/
    and got stuck in the below paragraph, the part that describes how to calculate the
     average percentage of CPU usage. 
    ==========
    All instances are included when calculating the average percentage of CPU usage and the average is
    based on use over the previous hour. Depending on the number of instances that your application is using, it can take longer than the specified wait time for the scale action to occur if the wait time is set very low. The minimum time between scaling actions
    is five minutes. Scaling actions cannot occur if any of the instances are in a transitioning state.
    ==========
    Does any one know the microsoft`s definition of 「All Instance」 ?
    Whether the virtual machines that are shut down but has been set into auto scaling group count as one of them?
    The question is that the response time, the data shows up in the management portal delays a lot comparing to the
    real time. I was wondering if the definition of the calculation described above is truly what the user`s want or not.
    I`m all ears to any information. Thanks in advance !! 

    Hello Tomo Shimazu,
    Instance is a presence of a service eg :- VM is an instance. Copy of VM is another instance which is 2 instances of VM.
    Although Microsoft’s pricing model is readily available and even offers a simple calculator (http://www.windowsazure.com/en-us/pricing/calculator/advanced/) to assist
    in the process, it may be difficult to know how much of each resource you will need to get an estimate.
    To understand on calculating the compute instances and the VM size, let’s first take a look at the VM role sizes offered by Microsoft.
    The prices per month for each, at the time of writing, are $30, $90, $180, $360, $720 from ExtraSmall to ExtraLarge respectively. So with the exception of the
    transition from ExtraSmall to Small, going to the next size VM is exactly twice the cost, which, is mirrored in the increase of resources you get at each level. With each step, CPU Cores, Memory, Disk Space, and Bandwidth are all doubled from the previous.
    If this is the case, then, is there any advantage to any one of these over the others? The answer is yes. In the majority of cases, the best bet will be to go with the small instance, with the reason being that because all of these resources scale equally
    to cost it is possible to achieve the exact equivalent to a larger VM simply by increasing the number of instances. For example 8 small instances is equivalent to one ExtraLarge instance, with the advantage of the fact that when not needed these small instances
    can be turned off and will cost nothing.
    By hosting the application in this manner, it increases the effectiveness of the number one reason that a business would transition to the cloud anyway – Scalability.
    Obviously 16 smaller instances can be more finely adjusted to the application’s usage than 2 ExtraLarge can. If traffic gets higher or lower than expected, two Small Instances can be added at $180/mo for the time that they are running, versus adding another
    ExtraLarge for $720/mo.
    The only exception to using the smallest instance, is in the case of the ExtraSmall, which offers only 1/20 of the bandwidth of the Small, making it only feasible
    for very lightly accessed applications or, more likely, a QA environment.
    From this point, it becomes much easier to estimate the compute instance requirements of migrating the application to Windows Azure. Take the current server(s)
    total resources (CPU, RAM, etc) and find how many Small instances it would take to recreate it. This gives a good starting point, however, remember that these instances can be turned on and off to meet demand, and beyond the first instance, there is no charge
    when the instances are off. This can lead to significant cost savings, and is the primary incentive to migrating to the cloud.
    For azure pricing information, refer
    pricing details.
    If you still unclear about pricing and billing, you may raise a service request with billing team
    here
    Hope this helps.
    Regards,
    Shirisha Paderu

  • Report for calculating capacity utilization and Efficency

    Hi,
    We are following REM in our company. The production line is defined in the production version. While backflushing the production line is called automatically and hence backflushing is done.
    We calculate the capacity utilization by using the formulae.
    Capacity Utilization = (Backflushed Qty/ Available capacity)*100.
    My queries are:
    1. Is there any standard report to determine the capacity utilization of a production line.
    2. Is there any standard report to calcualte the efficency of a production line.
    waiting for reply.
    With regards,
    Afzal

    Hi afzal
    1. you have mentioned ; Available capacity = Std.time per piece * no. of working hrs
    Let me explain with example
    suppose per piece if it takes 10 mins, now according to your formula
    A.C = 10* 24 * 60 = 14400 per day, but which is not correct
    normally if 10 mins/ peice means 6 peices/hr and for 24 hrs 24*6 = 144.
    so it must be A.C =  no. of working hrs / Std.time per piece.
    2. You have mentioned = capacity utlilised = total Backflushed qty per day., which means you are caluculating capacity utilization based on input material.
    3. Utilization = (Avaliable capacity/ Capacity utilised) * 100
    suppose let  us consider Available capacity per day =100
    capacity utilized = 50
    Utilization = (100/50) * 100 = 200%, which is not correct it should be only 50%
    Here my main doubt is why You are caluculating capacity based on input material.
    Please explanin  me you business process and whats the exact requirement so that I can help you out.
    Please check the formulae

  • What is the formula for calculating average cost for an item in inventory

    Hi,
    Can someone please share the formula to calculate average cost for an item in inventory which uses Average Costing?
    Thank you,
    Naren.

    HI
    When a transaction updates the average cost of an item, the new average cost is calculated as follows: 

  • What are some uses for the aggregate object and definition file?

    Can anyone share some examples for using the aggregate object in a Lookout process file? I've spent only a little bit of time with it, but I can't see how it provides any useful functionality. I guess I'm open to suggestions--thanks in advance! JT
    John T. Sampson

    If you want to reuse code in a modular sence than the Aggregate object will work. Although it works best to start the development with the intent to reuse that segment of code.
    Look at the Sequencer Object Example from the Developer Zone. Follow the README file to copy all files into the Lookout/Examples folder. The Help_Template is an Aggregate process that was used many times in different examples for the web. The state file, .l4t, holds the text that gives further details on the development of the example. The Sequencer process has an Aggregate object used in it to open the Help_template.
    Sequence Example

  • Formula for calculating the average takings for a given day in the week?

    I would like to calculate the average takings for each day of the week for a given financial year.

    Rick,
    I've looked at your document, made some additions and returned it to you. In your document you were not only using AVERAGE, but also MIN and MAX. Unfortunately, MIN and MAX don't have "IF" versions, so they can't be used to selectively operate on data matching criteria in a range.
    What I did to accommodate the need for MIN and MAX was to add a column for each criteria, in this case the different days of the week.
    In your document you also indicated the need for a Chart to graphically summarize the performance by day of the week. I rearranged your summary stats table to facilitate creating a chart from that table. I chose the mixed category chart with Bars for Min and Max and a Line for Average.
    Following are Screen Shots for the modified Data table, the Stats table and the Chart:
    The key expressions are:
    For Monday receipts:
    =IF(WEEKDAY($B)=2, $G, "")
    For Monday Minimum:
    =MIN(INDIRECT("Ledger::"&CHAR(70+ROW())))
    You had pre-filled Column A with 3-letter abbreviations of the Days of the Week. I am not sure this is important, since you could have formatted the Date (Column B) to show the same information, but I didn't like seeing the abbreviations for days that didn't have data entered yet so I replaced the text with an expression...
    =IF(LEN(B)>0, LEFT(DAYNAME(WEEKDAY(B)), 3), "")
    I seems that you may have filled the table with several months worth of rows of Mon, Tue, etc. Now, if you wish, you can trim the blank rows to just a few and add more as you need them.
    Let me know if you have any questions about maintaining the document.
    Jerry

  • Calculating  YTD AVG and QTD AVG

    Hi All,
    I am trying to crate custom measure formula for calculating  YTD AVG and QTD AVG in BPC 7.0 NW any help

    For this formula I am using Sum divided by..
    MEMBER [MEASURES].[YTD] AS 'IIF([%P_ACCT%].CURRENTMEMBER.PROPERTIES("2/CPMB/ACCTYPE")="INC",SUM(PERIODSTODATE([%TIME%].[LEVEL00], [%TIME%].CURRENTMEMBER),-[MEASURES].[/CPMB/SDATA]),IIF([%P_ACCT%].CURRENTMEMBER.PROPERTIES("2/CPMB/ACCTYPE")="EXP",SUM(PERIODSTODATE([%TIME%].[LEVEL00], [%TIME%].CURRENTMEMBER),[MEASURES].[/CPMB/SDATA]),IIF([%P_ACCT%].CURRENTMEMBER.PROPERTIES("2/CPMB/ACCTYPE")="AST",([MEASURES].[/CPMB/SDATA], CLOSINGPERIOD([%TIME%].[LEVEL02])),IIF([%P_ACCT%].CURRENTMEMBER.PROPERTIES("2/CPMB/ACCTYPE")="LEQ",-([MEASURES].[/CPMB/SDATA], CLOSINGPERIOD([%TIME%].[LEVEL02])),-[MEASURES].[/CPMB/SDATA]))))';SOLVE_ORDER=3
    can please help me..

  • How to use FORMULA in ABAP for calculation

    hi all,
    i have to do some calculation in my report and because of this reason i want to use formula. Could any body tell me the best way to use of formula for calculation purpose in ABAP or any other way?
    Thansk,
    abapfk
    Moderator Message: You don't need to open a thread to know the answer for this basic question. A simple search or using ABAP Help will help in getting the answer.
    Edited by: kishan P on Oct 4, 2010 11:20 AM

    There is another option to do the same thing.
    What can be done is, create running total. You can create running total from field explorer by right clicking and then new. Create Running Total Field dialog box appears. In that, provide the following:
    i)     Field to summarize - provide the field to maximize (i.e. id)
    ii)     Type of summary u2013 Maximum
    iii)     Evaluate u2013 On change of field (provide the name)
    iv)     Reset u2013 Never
    Keep this Running total field on the details section and suppress if you do not want to show it in the details section. Place this field wherever you want in the report.
    Hope this helps you. Let me know your comments.

  • What is the use of Alternative Calculation Type =2 and 4

    Dear Friends
    In pricing procedure in gross value, Net value for Item and Net value has Alternative calucation type is 2.
    What is the use of it?
    Without using it these value line are also fetching net value then what is the work of it. Please give me detail information with its effects in pricing condition tab page in sales document.
    Thanking You
    Arun

    Arun biswal,
    Correct Biswal. We have at varoius stages within Pricing procedure the "net value" which is calculated. Not only the alternative calculation type "2" is used if you notice carefully they are stored as subtotals at various levels.
    For Ex Gross Value  --> Subtotal =1 --> Calc type = 2
    similarly for Net value for Item --> Subtotal =2 --> Calc type = 2
    Net value 2 --> Subtotal =3 --> Calc type = 2
    See, these are used to calculate the net value at various levels in pricing. The calculation Type has got a set of routines that will facilitate us in pricing. SAP has provided certain clauclated formulas or routines to facilitate us during calculation within pricing . Here the "2" is used for calculation without tax and store it as subtotal and display it or use it for further calculations.
    We can use this "netvalue" amount for further calculations. It is used for clarity purpose when you issue a statement to customer. (like Confirmation order) at various levels like discount amt involved, Freight involved, Rebate amount invloved.....
    Even without this Calc type or using sub total u can proceed....
    Finally we have  TOTAL  --> Subtotal =A --> Calc type = 4
    In the above line we have Calc type as 4, which means when you use TAX this calc type is used .
    Routines are used to facilitate your process....
    Regards
    Sathya

Maybe you are looking for