Forum Discussion

JonathanK1999's avatar
JonathanK1999
Frequent Visitor
3 years ago

Dividing all rows by a calculated value

I have created an income statement, and want to divide every single row by the total sales row in a table that looks something like this: 

 

CategorySum of TotalDESIRED ANSWER
Sales $1,000.00 
Food $240.0024%
Clothing $56.006%
Beverages $60.006%
Tickets $644.0064%
COGS $840.0084%
Food $90.009%
Beverages $10.001%
Paper $40.004%
Labor $100.0010%
Rent $600.0060%
Non operating expense $90.009%
Admin. $50.005%
Water $40.004%
Total $70.007%

 

However, each time I try to divide to get the desired answer, I only get the % of the sales components, not of all other rows. I know that for me to get the % for clothing for instance I have to do individual functions like:

 

% clothing of total sales = (DIVIDE((CALCULATE(SUM(ConsolidadoPG[Sum of Total]), ConsolidadoPG[Codigo Unico Linea PG]="Clothing")), CALCULATE(SUM(ConsolidadoPG[Sum of Total]), ConsolidadoPG[Categoria]="Sales")))

 

But how can I create a formula that drags to all rows, and does not filter. So that in a column in the table that would be a row called % of total sales.

2 Replies

  • JonathanK1999 , try like

     

    % total sales = DIVIDE(CALCULATE(SUM(ConsolidadoPG[Sum of Total])), CALCULATE(SUM(ConsolidadoPG[Sum of Total]), ConsolidadoPG[Categoria]="Sales"))

     

     

    or

     

    % total sales = DIVIDE(CALCULATE(SUM(ConsolidadoPG[Sum of Total])), CALCULATE(SUM(ConsolidadoPG[Sum of Total]), Filter( all(ConsolidadoPG) , ConsolidadoPG[Categoria]="Sales")) )

     

    or

     

    % total sales = DIVIDE(CALCULATE(SUM(ConsolidadoPG[Sum of Total])), CALCULATE(SUM(ConsolidadoPG[Sum of Total]), Filter( allselected(ConsolidadoPG) , ConsolidadoPG[Categoria]="Sales")) )

    • JonathanK1999's avatar
      JonathanK1999
      Frequent Visitor

      Did not work, I am not getting the desired answer, and its just filtering for the values that fall under the sales sub category, such as food, clothing, beverages and tickets in the example above.