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
Arranafc19
Helper IV
Helper IV

Cumulative Percentage

I am working on a report which calculates the percentage of sold per month , with the null value being the ones not sold. I have managed to create the below dataset and calculated the percetages and I am able to plot this no problem.

 

Screen Shot 2019-07-15 at 20.04.29.png

I now however need to be able to find the cumulative value of the percetages to allow me to plot the rise per month , however I want to exclude the null values from the count. See below my required dataset look :

 

Screen Shot 2019-07-11 at 22.00.53.png

 

The cumulative percentage should not include the null month and should total from month one up.

 

I am using the below measure to calculate the percentage:

 

PercentageClosed = COUNTROWS('Actual v Expected')/CALCULATE(COUNTROWS('Actual v Expected'),ALLSELECTED('Actual v Expected'))

1 ACCEPTED SOLUTION

So you're very close.  ALLSELECTED returns all values that are currently being used in the table.  You just need to add an extra filter statement that specifically calls out blank month of closure as something you don't want included in this measure.

Cumulative Total =
CALCULATE (
          COUNT ( 'Actual v Expected'[Count] ),
    FILTER (
        ALLSELECTED ( 'Actual v Expected' ),
        ('Actual v Expected'[MONTH_OF_CLOSURE] <= MAX ( 'Actual v Expected'[MONTH_OF_CLOSURE] ) &&
('Actual v Expected'[MONTH_OF_CLOSURE] <> BLANK()) ) ))

 

View solution in original post

9 REPLIES 9
v-frfei-msft
Community Support
Community Support

Hi @Arranafc19 ,

 

We can create measures as below.

 

Measure = 
VAR a =
    MAX ( 'Table'[Month] ) - 1
RETURN
    IF (
        a <> 0,
        CALCULATE (
            SUM ( 'Table'[percentage] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Month] = a )
        )
    )
Measure 2 =
CALCULATE (
    SUMX ( 'Table', [Measure] ),
    FILTER ( ALL ( 'Table' ), 'Table'[Month] <= MAX ( 'Table'[Month] ) )
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @v-frfei-msft 

 

That didn't quite work as required, however maybe if I give a bit more context on my dataset , it may make more sense.

 

The table I am working off is called 'Comparison' and is made up of the below fields:

 

-> Month of closure which is calculated in the sql query by getting the datediff between the start and end date.

-> Count - this is creating when I grouped my dataset in power bi to count the number of rows per month of closure.

-> percentage closure -> how I am currently calculating the percetnage closed per month of closure using the below measure :

                            

PercentageClosed = COUNTROWS('Actual v Expected')/CALCULATE(COUNTROWS('Actual v Expected'),ALLSELECTED('Actual v Expected'))
 
From your screenshots below , this is close to what I require however I need month 1 to be included in the cumulative total and this is where the percentage total should begin.
Only the null month percentage should be excluded

So you're happy with how Percentage Closure is currently being calculated? If your only issue is setting up the cumulative sum of percentages to ignore blank values, we can do that.

 

Cumulative % = 
SUMX(
FILTER(
ALLSELECTED(Comparison),
Comparison[Month] <> BLANK() &&
Comparison[Month] <= SELECTEDVALUE(Comparison[Month])
),
[Percentage Closure]
)

 

Hi @Cmcmahan 

This didnt work for me, see my measure below amended to suit my dataset

measure.PNG

 

When I do this I get the following:

 

table.PNG

 

My dataset is called 'Actual v Expected' and i mention about the measure I am using for the PercentageClosed column.

 

Any ideas why this isn't working as required ?

Hi @Arranafc19 ,

 

Could you please share your sample data to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

hi  @v-frfei-msft @Cmcmahan  ,

 

i have managed to make progress

 

I am working on calculating the cumulative percentage for a set of data , however I only want the percentage to start totalling after the first row.

 

At present , I am getting the below:

 

Capture.PNG

The current measure I am using is 

 

 
Cumulative Total =
CALCULATE (
          COUNT ( 'Actual v Expected'[Count] ),
    FILTER (
        ALLSELECTED ( 'Actual v Expected' ),
        ('Actual v Expected'[MONTH_OF_CLOSURE] <= MAX ( 'Actual v Expected'[MONTH_OF_CLOSURE] ))
    ))
 
 
This is calculating the cumulative percentage correct but it is including my null month which I want to exclude.I need the measure to only start a running total on the rows where the month of closure is not null.
 
See below the expected outcome:
 
Capture2.PNG
 
As you can see , i need only from 0.4 down on the percentage close to total up , and I cant exclude the top row as I need them in the percetnage calculation.

So you're very close.  ALLSELECTED returns all values that are currently being used in the table.  You just need to add an extra filter statement that specifically calls out blank month of closure as something you don't want included in this measure.

Cumulative Total =
CALCULATE (
          COUNT ( 'Actual v Expected'[Count] ),
    FILTER (
        ALLSELECTED ( 'Actual v Expected' ),
        ('Actual v Expected'[MONTH_OF_CLOSURE] <= MAX ( 'Actual v Expected'[MONTH_OF_CLOSURE] ) &&
('Actual v Expected'[MONTH_OF_CLOSURE] <> BLANK()) ) ))

 

Cmcmahan
Resident Rockstar
Resident Rockstar

Try this:

PercentageClosed = COUNTROWS('Actual v Expected')/CALCULATE(COUNTROWS('Actual v Expected'),FILTER(ALLSELECTED('Actual v Expected'), Table[Month]<>BLANK()))

This way you're explicitly filtering out month where the number is blank in your calculation.

Hi @Cmcmahan 

 

this didnt work, What I am trying to achieve is to create a measure which calculates the cumulative percentage , but only starting from month one , not including the null values percentage 

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.

Top Solution Authors