Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
JJL_Ptbo
Frequent Visitor

Divide SUM of column in Table 1 by SUM of column in Table 2

I have tried this a number of ways. 

 

I have a All Months Case Summary Table. I need to get a count of the # of cases (by counting the participant ID column). 

Case Owner   Participant ID  Date

A                     1234              January

B                      5467             January

C                      8910             January

A                     1234              February

B                      5467             February

C                      8910             February

 

I have AP Summary Table. I need to take the # of APs overdue and divide it by the # of cases from the All Months table.

Case Owner   #APs Overdue  Date

A                     40           January

B                      20          January

C                      25          January

A                     41            February

B                      25           February

C                      26           February

 

I have two tables that complete the counts of the cases and the counts of Overdue APs for me 

OverDue AP =
SUMMARIZE(
    'AP Summary',
    'AP Summary'[Case Owner],
    'AP Summary'[Total Action Plan Overdue],
    'AP Summary'[Date],
    "OverDue AP", COUNTROWS('AP Summary'))
 
ParticipantCountByEmployee =
SUMMARIZE(
    'All Months Case Details',
    'All Months Case Details'[Case Owner],
    'All Months Case Details'[Participant ID],
    'All Months Case Details'[Date],
    "ParticipantCount", COUNTROWS('All Months Case Details')
)
 
Then the DIVIDE function produces the correct % when not considering Case Owner. 
Count AP Overdue divided by Count Cases = DIVIDE(SUM('OverDue AP'[Total Action Plan Overdue]),SUM(ParticipantCountByEmployee[ParticipantCount]),0)*100
 
When I try to add Case Owner as a filter to the visual see the % by Date (month) they are incorrect. Any insights appreciated.
6 REPLIES 6
JJL_Ptbo
Frequent Visitor

@Khushidesai0109 @v-linyulu-msft Any further thoughts on this? I still haven't found a solution. Thanks!

Khushidesai0109
Helper III
Helper III


Here's the final solution based on your requirements:

 

  1.     Calculate the Total Number of Cases by Case Owner and Month    :

 

  DAX

   TotalCases =

   CALCULATE(

       COUNTROWS('All Months Case Details'),

       ALLEXCEPT('All Months Case Details', 'All Months Case Details'[Case Owner], 'All Months Case Details'[Date])

   )

  

 

  1.     Calculate the Total Number of Overdue APs by Case Owner and Month    :

 

  DAX

   TotalOverdueAPs =

   CALCULATE(

       SUM('AP Summary'[#APs Overdue]),

       ALLEXCEPT('AP Summary', 'AP Summary'[Case Owner], 'AP Summary'[Date])

   )

  

 

  1.     Calculate the Percentage of Overdue APs for each Case Owner    :

 

  DAX

   PercentageOverdueAPs =

   DIVIDE(

       [TotalOverdueAPs],

       [TotalCases],

       0

   )

  

 

These measures should give you the correct percentage of overdue APs for each Case Owner, considering the total number of cases for each Case Owner and Month. You can then use these measures in your visualizations, applying filters for the desired month as needed.

 

Make sure your relationships between the tables are correctly set up to enable accurate filtering and aggregation based on the filters applied to your visuals.



If this post helps, please consider Accept as the solution to help the other members find it more quickly.
Give thumbs up as well!!

Thank You!!!

@Khushidesai0109 The first two calculations achieved the same output as my SUMMARIZE functions so the counts are correct. However, the DIVIDE function is still not producing the right % by Case Owner. 

 

And for Case Owners that don't have a row in that month for the OverAP table a % isn't generated, but rather the # Total # of OverAPs is listed for them instead. This is the output for the first few Case Owners when I add PercentageOverdueAPs and Case Owner as fields to a Table visual without Months:

 

Case Owner A has 301 APs overdue total and 1215 cases = 24.7%

Case Owner B has 0 APs overdue total and 1 case = 0% 

Case Owner C has 709 APs overdue total and 1191 cases = 59.5%

 

PercentageOverdueAPs       Case Owner 

11.76                                       A

14,290.00                                B

12.00                                       C

(14290 is the total # APs overdue) 

 

If I add in the date it just lists the same amount for every month. 

 

These are the relationships. 

JJL_Ptbo_0-1714688958442.png

 

v-linyulu-msft
Community Support
Community Support

Hi,@JJL_Ptbo 

First of all, in my understanding your requirement is to count case totals by Participant ID in Table 1, then count the combined number of people belonging to them in Table 2, and divide the two numbers to get the percentage. I think the reason why you have added the filter, the percent value is not correct is that you count the number of rows is not divided by the person who belongs to it, but you added the filter, he will only sift the data, you count is still the total of the whole table. If my understanding is wrong, please give me your relative opinion:

Regarding the issue you raised, my solution is as follows:

1.First I have created the following table and the column names and data are the data you have given:

vlinyulumsft_0-1714633307619.png

vlinyulumsft_1-1714633316347.png
2.To meet your needs, my measure are as follows:

 

Percentage divided = 
VAR countbyowener=CALCULATE(COUNTROWS('All Months Case Details'),FILTER(ALLSELECTED('All Months Case Details'),'All Months Case Details'[Participant ID]=MAX('All Months Case Details'[Participant ID])))
VAR conuntbyap=CALCULATE(COUNTROWS('AP Summary'),FILTER(ALLSELECTED('AP Summary'),'AP Summary'[Case Owner]=MAX('AP Summary'[Case Owner])))
RETURN
DIVIDE(countbyowener,conuntbyap,0)

 


3.You can also modify the percentages if you wish to implement them as I have shown below:

vlinyulumsft_2-1714633395955.png

4.Here's my final result, which I hope meets your requirements.

vlinyulumsft_3-1714633395957.png

vlinyulumsft_4-1714633409266.png

vlinyulumsft_5-1714633432228.png

Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

And I should say Participant ID is a text field. 

@v-linyulu-msft This gets me closer, but it still isn't producing the correct %. 

 

The # of Cases isn't by Participant ID the Participant ID represents the Case. And an AP is a requirement to have completed with a case and this metric is given as a total by that Case Owner in the table as opposed to by Participant/Case. I don't see an option to attach files, but this is sample in Power BI. In my real file there is a date table and an employee table the Case Owner field is Table 1 and 2 have relationships to the Employee table and Table 1 and 2 have relationships to the Date table.

 

All Months Case Details

JJL_Ptbo_0-1714648180390.png

AP Summary

JJL_Ptbo_1-1714648224539.png

Top Chart counting the # of cases with filters for Month and Case Owner. Bottom chart displaying # of APs overdue by Case Owner in December. The % of APs overdue for Case Owner A out of their total # cases in December should then be 50%. 

JJL_Ptbo_2-1714648231501.png

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.