Calculate percrentage based on 2 column and one filter

Hi,
I am looking for a way to compute percentage based one two column and 1 filter but i have a problem when every thing is checked on my filter.
The table as follow is my example:
ID
cat1
cat2
number
total
pct
1
a
aa
5
40
13%
1
a
ab
20
40
50%
1
a
ac
15
40
38%
1
b
ba
12
47
26%
1
b
bb
20
47
43%
1
b
bc
15
47
32%
2
a
aa
9
45
20%
2
a
ab
16
45
36%
2
a
ac
20
45
44%
2
b
ba
10
50
20%
2
b
bb
20
50
40%
2
b
bc
20
50
40%
I create a power table as follow:
Filter: column ID
Axis: cat1 and cat2
values: pct
The problem is when I want to select all my data in my filter, a sum/mean is done for pct but the results are wrong. Did I missed something ? Is there a way to correct the problem ?

Hi mi jo,
It appears that you have created your percentage as a Calculated Column and what you actually want is a Calculated Field.
You can create a Calculated Field by clicking on the Power Pivot ribbon and using a DAX formula similar to the following:
Percentage:=DIVIDE(SUM(TableName[number]), SUM(TableName[total]))
I have formatted this Calculated Field as a percentage and used it to create a Pivot Table:
Is this what you were after or have I misunderstood the problem?
Edit: Just took a quick look at the workbook and can see that the pct column is coming in as a fixed value for a row. The above solution should help. A best practice would be to first create a Calculated Field for each of the number and
total columns such as...
Sum of Number:=Sum(TableName[number])
And...
Sum of Total:=Sum(TableName[total])
And then finally update this DAX formula:
Percentage:=DIVIDE(SUM(TableName[number]), SUM(TableName[total]))
To this...
Percentage:=DIVIDE([Sum of Number], [Sum of Total])
Regards,
Michael Amadi
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to vote it as helpful :)
Website: http://www.nimblelearn.com
Blog: http://www.nimblelearn.com/blog
Twitter: @nimblelearn

Similar Messages

  • Resulting grid does not contain at least one row, one column and one POV

    I have upgraded to 9.3.3 recently.
    We have a front end app which will run MDX queries to retrieve data.
    Sometimes based on the users selections MDX query might get back nothing i.e will get #missing across all rows/columns and this works fine with the existing 9.3.1 essbase server.
    If I run the same query against a 9.3.3 essbase cube I get the error "Resulting grid does not contain at least one row, one column and one POV. If you have any suppress row options selected pls clear them."
    I DO NOT have Supress missing data/zero enabled. Not sure why I get this error even though I dont have that option enabled.
    Essbase 9.3.3 on HP-UX ITanium 11.31
    APS 9.3.3 on win 2003 R2
    Smartview 9.3.3 - also tried with smartview 9.3.1.6 and see the same error.
    Any suggestions to fix this issues?

    The front end is using a VBA command "hypexecutequery" and with 9.3.3 essbase I get a return code -9 which means Operation was cancelled as per the smartview doc.
    In 9.3.1 essbase I get the return code 0 which means the query is fine even if it does not return any data.
    The query I am using now will return nothing as it is a check to see if there is any data. But with 9.3.3 Essbase I get an error code -9 which looks like it does not like the syntax or something.
    Any suggestions?

  • Filling in values based on the column and row headers

    I have a question that seems simple, but I can't figure out how to do it and I've searched all over the forum to no avail.
    I have one column that is width increasing by 3 in. increments (column A)
    I have one row that is height increasing by 3 in. increments (row B)
    I have one cell that is price (cell A1)
    I have a formula to calculate price per sq. ft.: =CEILING(A3B2/144,1)A1. This gives me the whole sq. ft. number multiplied by the price per sq. ft. to give me a total price at that dimension (A3 is the width, B2 is the height, and A1 is the cell that contains the price per sq. ft.).
    *Here is the problem*: When I try to cut and paste or fill the formula to the other cells, it doesn't calculate the formula as =CEILING(column A * Row B/144,1)*A1. Instead, it moves all of the values relative to the new cell that the formula is being pasted or filled to.
    Is there a way to autofill the cells so that the formula continues to refer to the width column, the height row, and the price cell?

    Aha! Apparently I didn't do enough research before I posted and I have since answered my own question. Here's how you do it. Look for "Distinguishing Absolute and Relative Cell References" and you should be able to find what you need. In my case, here is the formula I needed to have to make the copy and paste function do what I needed it to do: =CEILING($A3*B$2/144,1)*$A$. Hope that helps anyone who may have had the same problem I did.

  • Trying to calculate value based on rounding up and then calculate date range excluding weekends..

    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.

  • Access data from from two lists based on lookup columns and insert into another

    Hi,
    I am new in SharePoint and is stuck in some problem.
    I want to insert data in to a list by fetching data from 2 lists.
    The scenario is :
    List A Columns : EmployeeName, EmployeeID, EmployeeSalary 
    List B Columns : DepartmentName, EmployeeID, ManagerID
    EmployeeID is lookup column 
    I want to fetch data from these 2 lists and insert data into another list:
    List C Columns: EmployeeName, EmployeeSalary, DepartmentName 
    Can someone please explain me all the possible approaches to do the above task

    If ListA and ListB are the lists that you created, it would be better to generate the lists data into one list not seperate lists, as they both represents the property information of one employee.
    If they are existing lists, you may have following considerations:
    1. if you are a programmer, it would be easier to have a lookup column at ListA, to generate the EmployeeName, EmplyeeSalary, then using ItemAdded event, to generate the DepartmentName column based on EmployeeID column.
    2. have a lookup column look at ListA, use workflow, set when item is created, start the workflow automatically, then in the workflow, find ListB related item based on EmployeeID column, to set the DepartmentName column, SharePoint designer workflow
    set Item Value activity can do this work, you can research to find more information about how to do this.
    Thanks,
    Qiao Wei <br/> My blog:http://blog.goobol.com

  • Unique row based on two columns and single column

    Dear Members,
    I have a table which contains duplicate rows, for which a query should be able to fetch the unique row from the table. Here the unique is not based on one column, but it should be on two columns and also check for uniqueness on one column.
    create table addr ( firstname varchar2(10), lastname varchar2(10), area varchar2(3));
    insert into addr values('bob', 'james', '1');
    insert into addr values('bob', 'james', '1');
    insert into addr values('harry', 'bert', '1');
    insert into addr values('jimmy', 'bert', '1');
    insert into addr values('sam', 'mac', '1');
    insert into addr values('sam', 'knight', '1');
    insert into addr values('tom', 'sand', '1');
    insert into addr values('cat', 'mud', '1');
    The output of query should contain 3 rows.
    bob - james
    harry - bert or jimmy - bert [ either one of them, but not both ]
    sam - mac or sam - knight [ either one of them, but not both ]
    tom - sand
    cat - mud
    SELECT firstname, lastname as total from addr WHERE area = '1' GROUP by firstname,lastname; This does not take of single column duplication..
    Any suggestions..

    SQL> with t_data
    as
    select 'bob' as firstname, 'james' as lastname, '1' as area from dual union all
    select 'bob', 'james', '1' from dual union all
    select 'harry', 'bert', '1' from dual union all
    select 'jimmy', 'bert', '1' from dual union all
    select 'sam', 'mac', '1' from dual union all
    select 'sam', 'knight', '1' from dual union all
    select 'tom', 'sand', '1' from dual union all
    select 'cat', 'mud', '1' from dual
    SELECT
            firstname,
            lastname,
            area
    FROM
                    SELECT
                            t.*,
                            row_number() over(partition BY firstname order by 1) rn,
                            row_number() over(partition BY lastname order by 1) rn1
                    FROM
                            t_data t
    WHERE
            rn     = 1
    AND rn1 =1 ; 
    FIRSTNAME       LASTNAME        AREA
    bob             james           1
    cat             mud             1
    jimmy           bert            1
    sam             knight          1
    tom             sand            1
    SQL>

  • 2 date columns and one dimension hierarchy

    Hi,
    I have one question in OBIEE 10g.
    I have one dimension table with 2 date columns (insertedOn, updatedOn)
    I created insertedOnYear, insertedOnMonth and updatedOnYear, updatedOnMonth columns from my date columns.
    I have hierarchy
    Year -> Month -> Day for that dimension table
    and I would like to dril down both columns insertedOnYear and updatedOnYear
    insertedOnYear -> insertedOnMonth -> insertedOn
    updatedOnYear-> updatedOnMonth -> updatedOn
    I am able to do it only for one of these columns and not for both.
    I can place both columns to appropriate levels, but drilling doesn´t work as I want
    Can you tell me how to solve my problem?

    Oops, I was talking about 11G. Ok no problem. Do this. In the physical layer, cretea 2 alias tables. Both pointing to the table where you have these 2 fields. The put everything in your BMM. There create the 2 hierarchies using the 2 different tables (that will point to the 2 alias tables create in the physical layer). This will make them unique.

  • Inheritance based on USER column and JPQL based on @ManyToOne column

    I wanted to build a simple inheritence scheme for no other reason than to support a generalized table that I could manipulate in standard libraries and to extend that table with columns that might exist in various customer implementations. In the extra-ordinarily simple example that follows I created a base Parcel class; extend that with a ParcelBean which has a column specific to a user; and extend that further with a wrapper class that will include some Trinidad references that I want to keep completely away from the bean classes. In short, I wanted to put together an inheritence scheme for basic OO reasons, not because of any particular table structure.
    After some thought I figured that the best way to do this might be to use the Single-Table Strategy, especially after I discovered that I could fool the system by using the Oracle USER pseudo-column for my DiscriminatorColumn and use my schema name for the DiscriminatorValue.
    @Entity
    @Table(name = "PARCEL")
    @Inheritance
    @DiscriminatorColumn(name = "USER")
    public class Parcel {
      String parcelPin;
      public Parcel() {
      @Id
      @Column(name = "PARCELPIN", nullable = false)
      public String getParcelPin() {
        return parcelPin;
      public void setParcelPin(String parcelPin) {
        this.parcelPin = parcelPin;
    @Entity
    public class ParcelBean extends Parcel {
      LandUseType luc;
      public ParcelBean() {
      public void setLuc(LandUseType newluc) {
        this.luc = newluc;
      @ManyToOne
      @JoinColumn(name = "LUC")
      public LandUseType getLuc() {
        return luc;
    @Entity
    @DiscriminatorValue("CPC")
    public class ParcelRow extends ParcelBean {
      public ParcelRow() {
      public void doSomething(ActionEvent ae) {
        ; // Trinidad code
    }For a couple of weeks this has been working fine. Right up until I tried to a JPQL like the following:
    "select p from ParcelRow p where p.luc.cpcCode=12"The problem is that TOPLINK will generate SQL that prefixes USER with an alias (something it does not do if there isn't a foreign key reference involved). This won't work because Oracle SQL does not allow aliases on pseudo-columns
    select USER from PARCEL; -- return CPC
    select p.USER from PARCEL p; -- throws ORA-01747: invalid user.table.column specificationSo now I'm in a jam. I can't (read won't if you will) give up on my requirement for inheritence. I have multiple clients with the same basic legacy table with minor variations and I have tens of thousands of lines of code that work on the basic core table properties and I don't want to copy and paste. I could use interfaces, except that I would still have to extend the Beans with my Row classes so that I could add the JSF actionListeners (and other such stuff). I need to be able to select Lists of these Row classes with the JSF methods so that I can expose them as values to JSF/Trinidad/ADF Tables and it break every person pattern I enforce to mix JSF and JPA dependencies in the same class.
    Anyone out there have any ideas?
    Thanks Mark

    Of course a simple fix for this problem would be if the Oracle provider code was smart enough to recognize pseudo columns and to not prefix them with an alias.
    Is there any chance that this might be done before a final release?
    Mark

  • How to calculate totals based on year (date) and comparing othe columns in the same table please

    Hello Good Evening,
    Could you please help me here
    how to write condition for self table year records, such 2012 name and acctno match with 2013 name and acctno then total, provided below,
    create table #tab1 (MasterKey int, AcctNo varchar(12),name varchar(25), SumaofShares numeric, request_dat datetime )
    --drop table #tab1
    insert into #tab1 values (1000, 100,'Tom', 2500, '10/01/2012')
    insert into #tab1 values (1001, 101,'Bat', 1550, '08/11/2012')
    insert into #tab1 values (1002, 102,'Kit', 1600, '06/12/2012')
    insert into #tab1 values (1003, 103,'Vat', 1750, '04/15/2012')
    insert into #tab1 values (1010, 104,'Sim',200, '04/21/2013')
    insert into #tab1 values (1011, 105,'Tim',500, '06/18/2013')
    insert into #tab1 values (1012, 100,'Tom',800, '08/22/2013')
    insert into #tab1 values (1013, 101,'Bat',550, '09/15/2013')
    insert into #tab1 values (1014, 100,'Pet',200, '02/21/2013')
    insert into #tab1 values (1015, 103,'Vat',150, '03/18/2013')
    insert into #tab1 values (1016, 110,'Sun',800, '03/22/2013')
    insert into #tab1 values (1017, 111,'Bet',550, '12/15/2013')
    insert into #tab1 values (9999, 111,'AAA',110, '12/15/2014')
    create table #tab2 (IssueKey int, totalOutstanding numeric, sharedBenefits varchar(1) )
    --drop table #tab2
    insert into #tab1 values (1000, 500, 'V')
    insert into #tab1 values (1001, 150, 'U')
    insert into #tab1 values (1002, 100, 'N')
    insert into #tab1 values (1003, 170, 'U')
    insert into #tab1 values (1010, 100, 'U')
    insert into #tab1 values (1011, 200, 'K')
    insert into #tab1 values (1012, 340, 'U')
    insert into #tab1 values (1013, 560, 'N')
    insert into #tab1 values (1014, 280, 'V')
    insert into #tab1 values (1015, 150, 'V')
    insert into #tab1 values (1016, 840, 'V')
    insert into #tab1 values (1017, 530, 'N')
    i would like to get 4 columns output
    how to get sumofshares (#tab1) and TotalOutStanding(#tab2) summ up with these values please.,
    MasterKey (#tab1) and IssueKey (#tab2) are like primary key and foreign key
    so the request is
    need to calculate, sumofshares (#tab1) and TotalOutStanding(#tab2) as below
    1)ShareBenefist = U and year( request_dat) in (2012 , 2103) and (Name for 2012 should match with 2013 name and 2012 Acctno should match with 2013 accounno) in (#tab1)
    then '2012 and 2013 accts UN Veriverted'
    2)ShareBenefist = V and year( request_dat) in (2012 , 2103) and (Name for 2012 should match with 2013 name and 2012 Acctno should match with 2013 accounno) in (#tab1)
    then '2012 and 2013 accts Veriverted'
    3)ShareBenefist = N and year( request_dat) in (2012 , 2103) and (Name for 2012 should match with 2013 name and 2012 Acctno should match with 2013 accounno) in (#tab1)
    then '2012 and 2013 accts NONVERT'
    4)year( request_dat) =2102 and Name and Acctno not match with 2013 account name and acctno (#tab1)
    then '2012 last year accounts'
    5)year( request_dat) = 2013 and Name and Acctno not match with 2013 account name and acctno (#tab1)
    then '2012 This year accounts'
    for ex 1) the below accounts in #tab1 has both 2012 and 2013 and acctno same in both years and name is same in both years so it is condired as
    insert into #tab1 values (1012, 100,'Tom',800, '08/22/2013')
    for ex 2)
    insert into #tab1 values (1013, 101,'Bat',550, '09/15/2013')
    for ex 4) 2012 records there is not match acctno and name in 2013 recods
    insert into #tab1 values (1002, 102,'Kit', 1600, '06/12/2012')
    for ex 5) 2013 records there is no match of name and acct no with 2012 records
    insert into #tab1 values (1010, 104,'Sim',200, '04/21/2013')
    insert into #tab1 values (1014, 100,'Pet',200, '02/21/2013')
    insert into #tab1 values (1016, 110,'Sun',800, '03/22/2013')
    insert into #tab1 values (1017, 111,'Bet',550, '12/15/2013')
    Expected Results (just for format)
    AcctTypeDescription, SumofShares, OtotalutStand
    '2012 and 2013 accts UN Veriverted',2700,234
    '2012 and 2013 accts Veriverted' ,2890,234
    '2012 and 2013 accts NONVERT' ,4533,325
    '2012 last year accounts' ,2334,567
    '2012 This year accounts' ,2222,877
    Please
    Thank youy in advance
    asita

    As I understand it, your sample output was only to show the format, and did not pretend to be give the exact result given the sample data. This is pity, because means that I was not able to verify that my query below gives the desired result.
    The exact relation between #tab1 and #tab2 is not clear to me. I'm making the assumption that a row in #tab1 may have zero or one row in #tab2, but not many.
    My solution has two CTEs. The first simply joins the tables together and extracts the year. In the second CTE, I perform a self-join over the first CTE which I have divided in two by year. This is a full join, since an account may appear for only one of
    the year. Note that it is instrumental to extract the year data in inner queries first.
    The final query is just an aggregation over the categories.
    create table #tab1 (MasterKey int, AcctNo varchar(12),name varchar(25), SumaofShares numeric, request_dat datetime )
    --drop table #tab1
    insert into #tab1 values (1000, 100,'Tom', 2500, '10/01/2012')
    insert into #tab1 values (1001, 101,'Bat', 1550, '08/11/2012')
    insert into #tab1 values (1002, 102,'Kit', 1600, '06/12/2012')
    insert into #tab1 values (1003, 103,'Vat', 1750, '04/15/2012')
    insert into #tab1 values (1010, 104,'Sim',200, '04/21/2013')
    insert into #tab1 values (1011, 105,'Tim',500, '06/18/2013')
    insert into #tab1 values (1012, 100,'Tom',800, '08/22/2013')
    insert into #tab1 values (1013, 101,'Bat',550, '09/15/2013')
    insert into #tab1 values (1014, 100,'Pet',200, '02/21/2013')
    insert into #tab1 values (1015, 103,'Vat',150, '03/18/2013')
    insert into #tab1 values (1016, 110,'Sun',800, '03/22/2013')
    insert into #tab1 values (1017, 111,'Bet',550, '12/15/2013')
    insert into #tab1 values (9999, 111,'AAA',110, '12/15/2014')
    create table #tab2 (IssueKey int, totalOutstanding numeric, sharedBenefits varchar(1)  )
    --drop table #tab2
    insert into #tab2 values (1000,  500,  'V')
    insert into #tab2 values (1001,  150,  'U')
    insert into #tab2 values (1002,  100,  'N')
    insert into #tab2 values (1003,  170,  'U')
    insert into #tab2 values (1010,  100,  'U')
    insert into #tab2 values (1011,  200,  'K')
    insert into #tab2 values (1012,  340,  'U')
    insert into #tab2 values (1013,  560,  'N')
    insert into #tab2 values (1014,  280,  'V')
    insert into #tab2 values (1015,  150,  'V')
    insert into #tab2 values (1016,  840,  'V')
    insert into #tab2 values (1017,  530,  'N')
    go
    WITH joined AS (
      SELECT a.MasterKey, a.AcctNo, a.name, a.SumaofShares,
             year(a.request_dat) AS year, b.totalOutstanding, b.sharedBenefits
      FROM   #tab1 a
      LEFT   JOIN #tab2 b ON a.MasterKey = b.IssueKey
    ), categories (category, sumofshares, totaloutstanding) AS (
       SELECT CASE WHEN A.MasterKey IS NOT NULL AND
                        B.MasterKey IS NOT NULL
                        THEN '2012 and 2013 accts ' +
                             CASE B.sharedBenefits
                                WHEN 'U' THEN 'UN Veriverted'
                                WHEN 'V' THEN 'Veriverted'
                                WHEN 'N' THEN 'NONVERTED'
                                ELSE ''
                             END
                   WHEN A.MasterKey IS NOT NULL THEN '2012 last year accounts'
                   WHEN B.MasterKey IS NOT NULL THEN '2013 this year accounts'
              END,
              coalesce(A.SumaofShares, 0) + coalesce(B.SumaofShares, 0),
              coalesce(A.totalOutstanding, 0) + coalesce(B.totalOutstanding, 0)
       FROM   (SELECT * FROM joined WHERE year = 2012) AS A
       FULL   JOIN (SELECT * FROM joined WHERE year = 2013) AS B
             ON A.AcctNo = B.AcctNo
            AND A.name   = B.name
    SELECT category, SUM(sumofshares) AS sumofshares,
           SUM(totaloutstanding) AS totaloutstanding
    FROM   categories
    GROUP  BY category
    go
    drop table #tab1, #tab2
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Read a file, calculate the momentum of two columns and calc a summation of them

    I have a file which das three columns. The first of them isn't important for this problem. I have to read the second and the thid ones, and then mutiply them (to calculate the momentum), if they are at the same line. After that I need to sum all the results that I calculated.
    How can I do this?

    If all the data in the file are numeric values you can use the Read From Spreedsheet File VI to get the 2-D array of data.  Then use the index array function and index out column 1 and 2.  Then multiple the arrays together, and then there is a Sum array elements VI that should finish it off.
    See the attached image
    Attachments:
    Temp.JPG ‏19 KB

  • Sum based on group by and one condition

    I have a tableof following structure
    Group SubGroup sequence length 
    A         x               1            10
    A         X        
        2            20
    A         X               2            30
    A         X               3            50 
    B         Y               4  30
    B         Y               5            40
    I needa new column with a sum of lengths grouping Group,sub group and sequence but the condition is sum should be calculated based on the sequence of each row.Sum is sum of lengths where sequence is greater than the current row sequence number and grouping
    group nad sub group
    following is the output i am looking for
    Group SubGroup sequence length   Sum
    A         x               1            10          100(Sum of all the lengths where sesquence > current rows sequence
                                                             and group by group,sub
    group and sequnce) 
    A         X               2            20          50
    A         X   3 30 NULL
    B         Y               4  40 50
    B         Y      5 50 NULL

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. 
    And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I have a table of following structure <<
    Your posting is crap! Did you know that GROUP and SEQUENCE are reserved words in SQL? Did you really want to use a CREATE SEQUENCE? Did you know a table has a name and key?? That having a separate “<something>_sub_group” column is so bad a design flaw
    it has a name (attribute splitting)? That “<something>_length” cannot exist without being the length of something in particular? 
    CREATE TABLE Rude_Postings
    (rudeness_grp CHAR(2) NOT NULL
     CHECK (rudeness_grp LIKE '[A-Z][A-Z]'),
     foobar_seq INTEGER NOT NULL
     CHECK (foobar_seq > 0),
     PRIMARY KEY (rudeness_grp, foobar_seq),
     foobar_length INTEGER NOT NULL
     CHECK (foobar_length > 0)
    The foobar_seq simply looks wrong. It was not unique, so it could not be a sequence by definition. I will guess that it is unique within a rudeness_grp. 
    INSERT INTO Rude_Postings
    VALUES
    ('AX', 1, 10),
    ('AX', 2, 20),
    ('AX', 3  30),
    ('AX', 4,  50),
    ('BY', 1 , 30),
    ('BY', 2 , 40);
    >> I need a new column with a sum of lengths grouping Group,sub group and sequence but the condition is sum should be calculated based on the sequence of each row. Sum [sic: SUM is a reserved word!] is sum of lengths where sequence is greater than the
    current row [sic: tables are sets not files, so there is no ordering and no concept of a current row] sequence number and grouping group and sub group << 
    Here is my guess:
    SELECT rudeness_grp, foobar_seq, foobar_length 
       SUM( foobar_length) 
           OVER (PARTITION BY  rudeness_grp 
                   ORDER BY  foobar_seq DESC
                   ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
         AS foobar_length_running_tot
      FROM Rude_Postings;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Calculate percrentage based on a distinct value

    Hi every one,
    I am trying to compute a percentage from a table which have got a strange format.
    here my example:
    ID
    Tribune
    Total
    Nomber
    110
    TRIBUNE OUEST
          49 833  
    505
    110
    TRIBUNE OUEST
          49 833  
    37
    110
    TRIBUNE OUEST
          49 833  
    99
    110
    TRIBUNE OUEST
          49 833  
    79
    25%
    110
    TRIBUNE OUEST
          49 833  
    307
    9%
    110
    TRIBUNE OUEST
          49 833  
    589
    110
    TRIBUNE OUEST
          49 833  
    1 247
    110
    TRIBUNE OUEST
          49 833  
    1 213
    110
    TRIBUNE OUEST
          49 833  
    545
    114
    TRIBUNE OUEST
    54 000
    991
    114
    TRIBUNE OUEST
    54 000
    518
    114
    TRIBUNE SUD
    54 000
    67
    114
    TRIBUNE SUD
    54 000
    953
    114
    TRIBUNE SUD
    54 000
    1 140
    110
    TRIBUNE SUD
          49 833  
    1 302
    110
    TRIBUNE SUD
          49 833  
    960
    110
    TRIBUNE SUD
          49 833  
    1 291
    110
    TRIBUNE SUD
          49 833  
    1 293
    110
    TRIBUNE SUD
          49 833  
    771
    110
    TRIBUNE SUD
          49 833  
    639
    114
    TRIBUNE EST
    54 000
    1 361
    110
    TRIBUNE EST
    49 833
    1 497
    So I have in my case ID which represent an event (here 110 and 114)
    For one ID there are many times the same number in the column "Total" which represent the total of place of the event. 
    !!! It is not the sum of each "Tribune" for instance for 110 the total places is 49833 and not 49833 * number of lines. !!!
    Same thing for others ID.
    The problem is, because of this, I cannot do divid(sum(total);sum(Nomber)) to get my percentage. Have any ideas how can take just one time the value in the column "total" ?
    Regards,
    Mijo

    You need to provide an example of your use case. This formula will work for the detail rows of a pivot table with ID or Tribune on rows/columns. It's very difficult to provide help without a detailed understanding of how a measure will be used, as everything
    is context-dependent.
    If you will be creating a pivot table without [ID] or [Tribune] on rows/columns, or you need totals to behave properly, then try this:
    Percentage:=
    DIVIDE(
    SUM( <table name>[Nomber] )
    , SUMX(
    DISTINCT( <table name>[Tribune] )
    , MAX( <table name>[Total] )

  • How to calculate the sum of multiple columns and enter it into a single col

    I have a table tab_contributions which has the following columns:
    Emp_code Current_month(format: yyyymm) Contribution_amt
    Sample entry:
    Emp_code Current_month Contribution_amt
    100 200910 100
    100 200911 100
    100 200912 100
    100 200912 100
    100 201001 100
    100 201002 100
    100 201003 100
    Desired output: Table_result
    Emp_code Years Contribution_amt
    100 2009-2010 700
    Also, the years duration should be of only one year. For eg: 2008-2009, 2009-2010 etc.
    Edited by: user9027633 on Feb 26, 2010 12:34 AM

    Select Emp_code, min(substr(Current_month,1,4))||'-'||max(substr(Current_month,1,4)) period, sum(Contribution_amt) amount
    from mytable
    group by Emp_code;
    SQL> with mytable as (
      2  select 100 Emp_code, 200910 Current_month, 100 Contribution_amt from dual union all
      3  select 100, 200911, 100 from dual union all
      4  select 100, 200912, 100 from dual union all
      5  select 100, 200912, 100 from dual union all
      6  select 100, 201001, 100 from dual union all
      7  select 100, 201002, 100 from dual union all
      8  select 100, 201003, 100 from dual)
      9  Select Emp_code,
    10         min(substr(Current_month,1,4))||'-'||
    11         max(substr(Current_month,1,4)) period,
    12         sum(Contribution_amt) amount
    13  from mytable
    14  group by Emp_code;
      EMP_CODE PERIOD        AMOUNT
           100 2009-2010        700Max
    http://oracleitalia.wordpress.com
    Edited by: Massimo Ruocchio on Feb 26, 2010 9:11 AM
    Added example

  • Including both the Jquery script to calculate the total of calculated column and freeze header row

    Hi
    I managed to get this code from here,
    http://techtrainingnotes.blogspot.in/2013/03/freezing-title-row-of-sharepoint-2010.html done on the page 
    I also managed to get this code from here, http://www.sharepointed.com/2012/11/28/jquery-total-calculated-column-in-sharpoint-2010/ done on another page.
    However, I need this to be done on the same page. When I do this, I only get the freeze header thingy to be up and not the calculated column. Could something be blocking. 

    Hi,
    You take the code below for a try in your environment after modified it a bit to suit the structure of your page:
    <script type="text/javascript" src="../../SiteAssets/js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    // update the list after the page has loaded
    _spBodyOnLoadFunctionNames.push("TTNListScroll");
    function TTNListScroll()
    // Scrolling list code from TechTrainingNotes.blogspot.com
    // Edit the next line with your list's summary name
    var SummaryName = "List28_frozenheader ";
    var TTNmyTable;
    var TTNListDiv = document.createElement('div');
    var TTNHeadingDiv = document.createElement('div');
    var tables = document.getElementsByTagName("table");
    for (var i=0;i<tables.length;i++)
    if(tables[i].summary == SummaryName)
    TTNmyTable = tables[i];
    break;
    if(TTNmyTable == undefined)
    // // Table not found!
    // you may want to comment out the next line after testing
    alert("table '" + SummaryName + "' not found");
    return;
    // make a copy of the table for the heading area
    TTNHeadingDiv.appendChild(TTNmyTable.cloneNode(true));
    TTNHeadingDiv.id="TTNheading";
    TTNListDiv.appendChild(TTNmyTable.cloneNode(true));
    TTNListDiv.id="TTNlist";
    TTNListDiv.width="100%";
    // udpate the page
    var TTNnode = TTNmyTable.parentNode;
    TTNnode.replaceChild(TTNHeadingDiv, TTNmyTable);
    TTNnode.appendChild(TTNListDiv);
    // hide the heading row of the main list
    TTNListDiv.childNodes[0].rows[0].style.visibility='hidden';
    // make the DIV for the heading the same width as the main list
    TTNHeadingDiv.childNodes[0].style.width = TTNListDiv.childNodes[0].offsetWidth;
    getSum(3);
    //pass the column number to this function
    function getSum(col)
    var m = "$"; //change to "" for non-money format
    var arrayList = $("table.ms-listviewtable:first> tbody> tr:gt(0)").find(">td:eq("+col+")");
    var x = 0;
    var p1 = "";
    var p2 = "";
    $.each(arrayList, function(){
    //console.log('$(this).text(): '+$(this).text());
    x += Number($(this).text().replace(/\$|,|\)/g, "").replace(/\(/g,"-"));
    //console.log('x: '+x);
    //format for negative numbers
    if (x < 0)
    p1 = "(";
    p2 = ")";
    x = Math.abs(x);
    $('#diidSortcal').attr('visibility','visible');
    $('#diidSortcal').text($('#diidSortcal').text()+'(sum: '+x+')');
    function addCommas(nStr)
    //formats number
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1))
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
    return x1 + x2;
    </script>
    <style type="text/css">
    #TTNheading
    height:28px;
    #TTNlist
    height:200px;
    overflow-y:scroll !important;
    overflow-x:auto
    </style>
    Then you might get something like this:
    Feel free to reply if there are still any questions.
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to calculate age based on current month and over the next 12 months in Webi 4.1

    Hi,
    I am working on a report where I need to show employees who turned 65 from the time the report is run to over the next 12 months.I have the 'Date of Birth' field available. I am using Bex Query as a data source and webi 4.1. How do I calculate this in Webi 4.1. I appreciate any help.
    Thank you,
    Charvi.

    Hi Charvi,
    Get the all employees who are all in 64 age bucket till yesterday.  Keep indicator for these employees.
    Then obviously these employees will be falling in 65 age in coming 12 months/365 days.
    Same you can get at Bex level also. Create formulae :
    if employee age = 64 then 1 else 0.
    (AGE = 64 * 1 + 0)
    Then create condition on this formulae as Value = 1.
    Revert back your feedback.
    Regards, Vijay

Maybe you are looking for

  • How can I configure a 802.1x in a switch 2960 with IOS 15.0.2?

    Hi, I'm trying to config a switch WS-C2960+24PC-L with IOS 15.0(2)SE5 and C2960-LANBASEK9-M to use 802.1x in my network but when I type the following commands the IOS doesn't recognize the interface commands and I can't complete the settings: Router#

  • Errror occured in shared data set report

    DECLARE @COMMODITY_ID_LIST as Commodity_ID_TBLTYPE; DECLARE @POINT_ID_LIST as Point_ID_TBLTYPE; INSERT @COMMODITY_ID_LIST VALUES (@COMMODITY_ID) DELETE @COMMODITY_ID_LIST WHERE (@COMMODITY_ID) < 0 EXEC USP_DIM_FACILITY @CUSTOMER_ID,  NULL, 'BMS', @CO

  • Bug in ODT 11720 - indexed columns list in Design Table is disabled

    Start VS2008 Server Explorer Expand any oracle db Expand Tables Design any existing table that has an existing index that indexes more than 3 columns Click Indexes tab Click the index name Try to scroll the list of indexed columns, because youre curi

  • Error code 207

    error code 206 and/or 207 keeps popping up and quits downloading creative cloud evrytime i need help on this.@

  • Additional attribute to Approval task

    Hi All, Can we add additonal attributes to Approval task. My scenario is as below. Requester raise the request using self service to assign the role to beneficiary and the request goes to approver. Approver login and go Approvals then click on reques