Global AI and Data Science

 View Only
Expand all | Collapse all

how can I get the accumulated percentage by column

  • 1.  how can I get the accumulated percentage by column

    Posted Fri October 21, 2022 10:23 AM
    a query in a report in ibm cognos in a cross table how can I get the accumulated percentage by column example column A HAS A QUANTITY.. COLUMN B IS THE SUM OF THE QUANTITY OF COLUMN A PLUS THE QUANTITY OF COLUMN B AND SO ON                                                               


    Status         / COLUMN A / COLUMN B / COLUMN C
    Closed             10 /                     20 /            5
    Open               15 /                 10 /               10
    TOTAL            25 /                 30 /               15

    ACCUMULATED PERCENTAGE

    Status  / COLUMN A /    COLUMN B             / COLUMN C
    Closed             40% / (10+20/55)->  55%   /        50%
    Open               60% /            45% /                    50%
    TOTAL            100%  /           100% /                100%

    ------------------------------
    rosario scarlett prado
    ------------------------------



    #AIandDSSkills
    #AIandDSSkills
    #AICertificate


  • 2.  RE: how can I get the accumulated percentage by column

    Posted Fri January 20, 2023 06:52 AM

    You can get the accumulated percentage by column by summing up the values in the column and then dividing each value by the sum and multiplying by 100 to get the percentage. This can be done using a formula or a function in a spreadsheet program or programming language.

    For example, in a spreadsheet program like Excel or Google Sheets, you can use the SUM function to sum up the values in a column, and then use the formula "=value/SUM(column)*100" for each cell in the column to get the percentage.

    In programming languages like Python, you can use the pandas library to read in a dataframe, sum the values of a column, and then divide each value of the column by the sum and multiply by 100.

    import pandas as pd
    
    df = pd.read_csv("data.csv")
    sum_column = df["column"].sum()
    df["percentage"] = df["column"]/sum_column*100
    

    Finally, you can also get the accumulated percentage by using the cumulative sum of the column, and dividing each value by the total sum and multiplying by 100.
    seo11.pro

    df["cumulative_percentage"] = df["column"].cumsum()/df["column"].sum()*100
    


    ------------------------------
    david johan
    ------------------------------