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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
UDMH
Frequent Visitor

Power BI Running total for Divide function

For Example,

Here I have a sales data against Product.

UDMH_0-1719479244600.png

 





1 ACCEPTED SOLUTION

Hi @UDMH ,

 

For the number of rows add a table with the folowing data:

MFelix_0-1719580218989.png

 

 

Add the following measures:

Percent Rank = RANKX ( ALLSELECTED(  Sales ), [Sales], , DESC )

Percent Running Total = 
VAR __rank = [_Percent Rank]
RETURN
SUMX (  FILTER ( ALLSELECTED ( Sales ), [Percent Rank] <= __rank ), [Sales] ) 

Nº Items = 
VAR __countBelowPercent =  [Sales]  * SELECTEDVALUE('Category'[Min])--store threshold percentabge
VAR __countBelowPercent1 =  [Sales]  * SELECTEDVALUE('Category'[MAX])
RETURN 
COUNTX ( 
    Sales, 
    IF ( [_Percent Running Total] >= __countBelowPercent  && [_Percent Running Total] <= __countBelowPercent1  , 1 ) 
) 

MFelix_1-1719580267724.png

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

5 REPLIES 5
MFelix
Super User
Super User

Hi @UDMH ,

 

Create the following measures:

Sales = SUM(Sales[Values])

Percentage = DIVIDE(
			[Sales],
			CALCULATE(
				[Sales],
				REMOVEFILTERS(Sales[Prod])
			)
		)


Running Sum Percentage = CALCULATE(
			[Percentage],
			WINDOW(
				1,
				ABS,
				0,
				REL,
				SUMMARIZE(
					ALLSELECTED(Sales),
					Sales[Prod],
					"SalesTotal", [Sales]
				),
				ORDERBY(
					[SalesTotal],
					DESC
				)
			)
		)

MFelix_0-1719482618551.png

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



UDMH
Frequent Visitor

But, how this works based on year wise data

Hi @UDMH 


What do you mean by a Year wise data?

In the example you gave there was only Product and Sales Amount. Can you please elaborate on the final result you need to achieve,


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



UDMH
Frequent Visitor

Hi @MFelix ,

Thank you for your support.

I have few more steps to bring the output.

UDMH_0-1719557232737.png

 

After getting running sum percentage, I need to categorize this one under A, B, C.
The output should be,

UDMH_1-1719557432412.png

Since this is a measure, the listing of category is not working.
And, also the sales data is huge, since we're using summarize in the measure, it keeps on loading and finally show error as visual exceeding the limits.
Whether there is any alternate way to the solution?

 




Hi @UDMH ,

 

For the number of rows add a table with the folowing data:

MFelix_0-1719580218989.png

 

 

Add the following measures:

Percent Rank = RANKX ( ALLSELECTED(  Sales ), [Sales], , DESC )

Percent Running Total = 
VAR __rank = [_Percent Rank]
RETURN
SUMX (  FILTER ( ALLSELECTED ( Sales ), [Percent Rank] <= __rank ), [Sales] ) 

Nº Items = 
VAR __countBelowPercent =  [Sales]  * SELECTEDVALUE('Category'[Min])--store threshold percentabge
VAR __countBelowPercent1 =  [Sales]  * SELECTEDVALUE('Category'[MAX])
RETURN 
COUNTX ( 
    Sales, 
    IF ( [_Percent Running Total] >= __countBelowPercent  && [_Percent Running Total] <= __countBelowPercent1  , 1 ) 
) 

MFelix_1-1719580267724.png

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.