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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply

cumulative count of grouped percentages without being filtered

Hi experts,

 

My data is as follow:

Each ID is an unique product.

Products was sent and its sending time is in column "Sending week", its receiving time is in column "Receiving week". Time is count by week number in a year. 

if column "Receiving week" is blank, it means " haven't received yet".

 

IDSending weekReceiving week
100week 1 
182week 1week 47
183week 1week 47
199week 1 
200week 1 
184week 1week 45
185week 2week 46
186week 2week 45
187week 3week 47
188week 3week 45
189week 3week 45
190week 3week 46
191week 3week 46
192week 3week 47

 

I want to create a column/measure in order to calculate grouped percentages of received products compared with the total number sent products. For example:

- total send of week 1 = count of all week 1 in column A = counta(week 1) = 5

 

- % receive up to week number 45 of send in week number 1 = count of column D (week 45)/count of column A(week1) = 1/5 = 20%

 

- % receive up to week number 47 of send in week number 1 = count of column D (week 47) + (week 45)/count of column A(week1) = (2 + 1)/5 = 60%

 

Desired output:

 

         Explanation 
sending week receiving week count of receiving week Percentage  count of receiving week (per sending week)receiving percentage
week 1 week 45 1 20%  1(= week 45 appears once from "sending week" week 1)20% because = count of "week 45"/count of sending week " week 1"= 1/5
week 1 week 47 2 60%  2 (=week 47 appears 2 times from "sending week" week 1)60% because = count of "week 45" + count of "week 46" + count of "week 47" =  (1+0 +2)/5
week 2 week 45 1 50%  150% because =count of "week 45"/count of sending week"week 2"= 1/2
week 2 week 46 1 100%  1100% because =count of "week 45" + count of "week 46"/count of sending week"week 2"= (1+ 1)/2
week 3 week 45 2 33%  2 33%  because =1/3
week 3 week 46 2 66%  266% because = (1+1)/3
week 3 week 47 2 100%  2100% because = (1+1+1)/3

 

The problem is that once I filter a "receiving week", column "sending week" accordingly is filtered, which lead to the percentage of receiving week/sending week is always 100%- incorrect.

 

I would like to consult you and hopefully this issue can be solved.

 

Many thanks and regards,

Cindy

4 REPLIES 4
v-haibl-msft
Employee
Employee

@BusinessAnalyst

 

Please check if following formulas are what you want.

 

  1. Create a column to store the receiving week number.
    Receiving week Num = 
    VALUE ( RIGHT ( Table1[Receiving week], 2 ) )
  2. Create a measure to calculate the count of receiving week.
    count of receiving week = 
    COUNTA ( Table1[Receiving week] )
  3. Create a measure to calculate the percentage.
    Percentage = 
    VAR Moving_Count_Of_Receiving_Week =
        CALCULATE (
            COUNTA ( Table1[Receiving week] ),
            FILTER (
                ALLEXCEPT ( Table1, Table1[Sending week] ),
                Table1[Receiving week Num] <= MAX ( Table1[Receiving week Num] )
            )
        )
    VAR All_Count_Of_Receiving_Week =
        CALCULATE (
            COUNTA ( Table1[Sending week] ),
            ALLEXCEPT ( Table1, Table1[Sending week] )
        )
    RETURN
    ( DIVIDE ( Moving_Count_Of_Receiving_Week, All_Count_Of_Receiving_Week ) )

count grouped percentages without being filtered_1.jpgcount grouped percentages without being filtered_2.jpg

 

Best Regards,

Herbert

Thank you very much for your great solution and your clear explanation. It was a huge help for me. 

 

In my sample data, receiving week values are only week 45, 47 for the products sent in week 1.

 

In reality, I need to check the cumulative percentage up to present time. For example now was week 49, I would like to see in week 49, how many percentage of products that was sent from week 1. Because there is no product coming in week 48 and week 49, so the cumulative percentage up to week 49 is still 50%.

 

Is that possilble to see that?

 

Thanks again for your contribution!

 

Have a nice day!
Cindy

 

 

@BusinessAnalyst

 

I’ve received your PBIX file but I’m still a little confused about your requirement.

 

For the first one -- when I choose week 16 from "sending week", and filter Denmark from "country", the percentage should be 100%. Could you please explain the calculation method with the public sample data in your initial post?

 

For another wish, I also would like you to explain the calculation method with the public sample data. Sorry to trouble you…

 

Best Regards,

Herbert

BhaveshPatel
Community Champion
Community Champion

if you can provide a link to your data, I can provide you the exact solution.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.