Forum Discussion

macgeorge's avatar
macgeorge
Helper I
3 years ago
Solved

Percentage Column

Hi, I am having trouble with this table please see fig. a. It report view it shows this table with the wrong percentage totals for product 1 and 3.

 

Fig. a

 

I am using this code to work out the percentage and add a column:

 

% Compliant = ('Outcomes'[Spot Checks Compliant]/[Spot Checks Totals])
 
It is calculating the percentage based on the number of times the product number appears and then totalling the percentage. This is wrong. 
 
Fig. b - this is what the source data table looks like. 

 

 

I want the % Compliant field with the correct row percentages as shown here in fig. c:

 

Fig c - this shows the unique product number with the correct percentage compliant:

 

 

In fig.a it is presenting the product numbers correctly, but its adding the percentages together instead of consolidating the product number and then providing an overall percentage like in fig. c.

 

Is there anything that I can add to the code above that will do this please?

 

Thank you,

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi macgeorge ,

     

    Please try:

    %  Compliant = DIVIDE(SUM('Table'[Spot Checks Compliant]),SUM('Table'[Spot Checks Total]))

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data

6 Replies

  • Hello Ibendin, 

    This is the 'Outcomes' table (Fig. a) I am using.

    Fig. a

    PrioritySpot Checks TotalsSpot Checks Compliant% Compliant
    PRODUCT 1200%
    PRODUCT 15360%
    PRODUCT 133100%
    PRODUCT 2800%
    PRODUCT 424023096%
    PRODUCT 315615197%
    PRODUCT 317717297%
    PRODUCT 32121100%
    PRODUCT 5462452%

     

    When I add a new column and use the DAX code below I get this table (Fig. b).

    % Compliant = ('Outcomes'[Spot Checks Compliant]/[Spot Checks Totals])

     

    Fig. b 

    PrioritySpot Checks TotalsSpot Checks Compliant% Compliant
    PRODUCT 1106160%
    PRODUCT 2800%
    PRODUCT 4240230192%
    PRODUCT 3354344494%
    PRODUCT 54624104%

     

    The calculations in Fig. b for Spot Checks Totals and Spot Checks Compliant columns are correct. For example the code divides Spot Checks Compliant "6", with Spot Checks Totals "10" presents the % Compliant total (referencing Fig. A) incorrectly, when it should present 60% and not 160%.

     

    Fig. c shows how I want the data to be presented in the required table below.

     

    Fig. c

    PrioritySpot Checks TotalsSpot Checks Compliant% Compliant
    PRODUCT 110660%
    PRODUCT 2800%
    PRODUCT 424023096%
    PRODUCT 335434497%
    PRODUCT 5462452%

     

    Is there anyway to use the totals as above in Fig. b and to produce the % on that table totals.

     

    Does this make sense?

     

    Thank you,



     

  • Apologies the tables seem to have lost its formatting - they should look like this:

     

    Fig. a

     

    Fig. b

     

    Fig. c

     

     

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi macgeorge ,

     

    Please try:

    %  Compliant = DIVIDE(SUM('Table'[Spot Checks Compliant]),SUM('Table'[Spot Checks Total]))

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data