Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Dynamic Average calculation

Hi All,

I have a requirement to calculate the average for my data as below. Directly using the average is not giving me the right results. Data is:

Requirement is to calculate the average of "# of business days", so the logic to be used is sum of( "# of business days") divided by (unique "Submission Number").

From the example above, number of unique submission number =4 and sum of # of business days=58, the result should be 58 divided by 4=14.5.

I have used the below logic

created measure , 1. sum = sum(business days) and 2. count = distinctcount(submission numbers).

My overall dataset has 5779 unique submission numbers, I am filtering my data for 4 submission numbers as shown above, but the count of submission numbers still remains 5779 , expected data  should be 4, due to which the average calucation is going wrong.

I have slicers addded for different fields shown in the data above, based on the selections I make, the count of submission numbers should change dynamically but it always shows as 5779 for me.

Can someone please let me know how to fix.

 

Sample data after filtering:

Please use the below data, overall submission numbers=5

out of this, if i filter the data as above screenshot, the submission numbers should be 4 and average should be 58/4.

 

Submission NumberAdminPISubmission typeSubmission StatusBoard NameReview CategoryWorkflow StatusWorkflow Status DateDepartmentDivision# of Business Days
0005004414-02  AmendmentApprovedExpeditedExpeditedAssigning for Prereview4/30/2019   
0005004414-02  AmendmentApprovedExpeditedExpeditedStaff Pre-Review4/30/2019  0
0005004414-02  AmendmentApprovedExpeditedExpeditedPre-Review Modifications Required5/6/2019  4
0005004414-02  AmendmentApprovedExpeditedExpeditedPre-Review Modifications Response5/7/2019  1
0005004414-02  AmendmentApprovedExpeditedExpeditedAssigned to Agenda5/7/2019  0
0005004414-02  AmendmentApprovedExpeditedExpeditedApproved5/17/2019  8
0005004414-03  Continuing ReviewApprovedExpeditedExpeditedAssigning for Prereview1/31/2020   
0005004414-03  Continuing ReviewApprovedExpeditedExpeditedStaff Pre-Review2/3/2020  1
0005004414-03  Continuing ReviewApprovedExpeditedExpeditedPre-Review Modifications Required2/27/2020  18
0005004414-03  Continuing ReviewApprovedExpeditedExpeditedPre-Review Modifications Response2/27/2020  0
0005004414-03  Continuing ReviewApprovedExpeditedExpeditedPre-Review Modifications Required2/28/2020  1
0005004414-03  Continuing ReviewApprovedExpeditedExpeditedPre-Review Modifications Response2/28/2020  0
0005004414-03  Continuing ReviewApprovedExpeditedExpeditedAssigned to Agenda3/3/2020  2
0005004414-03  Continuing ReviewApprovedExpeditedExpeditedApproved3/19/2020  12
0007004497-01  Continuing ReviewApprovedExpeditedExpeditedAssigning for Prereview5/30/2019   
0007004497-01  Continuing ReviewApprovedExpeditedExpeditedStaff Pre-Review5/30/2019  0
0007004497-01  Continuing ReviewApprovedExpeditedExpeditedAssigned to Agenda6/6/2019  5
0007004497-01  Continuing ReviewApprovedExpeditedExpeditedApproved6/14/2019  6
0007004497-02  Continuing ReviewApprovedExpeditedExpeditedAssigning for Prereview5/8/2020   
0007004497-09  Continuing ReviewApprovedExpeditedExpeditedAssigning for Prereview5/8/2020   15
0007004497-09  Continuing ReviewApprovedExpeditedExpeditedAssigning for Prereview5/8/2020   1

Thank you,

Poojitha

  • Hi Anonymous ,

     

    There is no problem with your formula.  It's just that your measure doesn't get the right compute context for it. How did you filter you table? If you filter it in query editor, it will show like what you want.

     

     

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

     

    Best Regards,

    Dedmon Dai

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

     

    You might need Net Work Days here: https://community.powerbi.com/t5/Quick-Measures-Gallery/Net-Work-Days/m-p/367362#M109

    • Anonymous's avatar
      Anonymous
      Not applicable

      Sample data attached, Can someone please help on fixing this.

      • v-deddai1-msft's avatar
        v-deddai1-msft
        Community Support

        Hi Anonymous ,

         

        There is no problem with your formula.  It's just that your measure doesn't get the right compute context for it. How did you filter you table? If you filter it in query editor, it will show like what you want.

         

         

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

         

        Best Regards,

        Dedmon Dai

  • Anonymous's avatar
    Anonymous
    Not applicable

    Screenshot from Power BI:

    Though the data has only two submission numbers, the overall data is shown as 5779 instead of 2. The expected output should be 47 divided by 2 ,but in Power BI report I get 47/5779.