Thumbnail of the article "Rank, Running Total and % of Total by Group in Power BI": a sample matrix with Rank, Running Total and % of Total columns

POWER BI · MATRIX CALCULATIONS

Rank, Running Total and % of Total by Group in Power BI

November 2026about 9 min readPower BIDAXQuick Calculations

QUICK ANSWER

There are three ways to rank, accumulate and take a share of total by group in a Power BI matrix. DAX measures (RANKX, a CALCULATE running total, DIVIDE with ALLSELECTED) work in any visual, but each calculation is its own measure. Visual calculations are shorter, but the report author creates them in edit mode, so a reader of the published report cannot add one. Quick Calculations in Flexa Tables are picked per value column inside the visual, with no extra measure in the model. In all three, a rank or a running total needs a base measure, and in Flexa Tables the Total row stays blank for both.

1. Why each rank and share becomes another measure

A matrix of Revenue by Region and Product invites three follow-up questions. Which products rank first in each region? How much of the region have the first few products added up to? What share of the region does each product carry?

Each one is a different calculation over the same number. In a classic model each becomes its own measure: one for the rank, one for the running total, one for the share of the parent, one for the share of the grand total. Repeat that for each metric in the report and the model fills up with measures that exist to read one number in a different way.

The question comes up on the Fabric Community forum under titles such as "Running Total with Matrix", "Cumulative of a measure based on Ranking" and "Percent of Total". The logic is not hard. What makes each version fiddly is the matrix context it has to survive: subtotals, slicers and the sort order the reader sees.

DAX MEASURES

Each calculation is a measure you write and keep in the model.

IN THE MODEL

fxRevenuefxRank in RegionfxRunning Total in Regionfx% of Region

IN THE TABLE

ProductRevenueRank in RegionRunning Total in Region% of Region
Alpha500150031.3%
Bravo400290025.0%
Charlie40021,30025.0%

4 measures, 4 value columns

QUICK CALCULATIONS IN FLEXA TABLES

The calculation is chosen on the value column.

IN THE MODEL

Revenue

Nothing else to write.

IN THE TABLE

ProductRevenue
Rank ↓ Down ⌄
Alpha1
Bravo2
Charlie2
Absolute
Running Total ↓ Down
% of Parent Row ↓
% of Grand Total
Rank ↓ Down ✓

1 measure, the calculation switches from a list

Figure 1. Where the calculation lives. With DAX it sits in the model as one measure per column. In Flexa Tables it is chosen on the value column. Illustration, sample data.

2. The foundation all three approaches share

Each option below starts from one base measure and a matrix with Region and Product on rows, sorted by Revenue in descending order within each region:

Revenue = SUM ( Sales[Amount] )

The examples use the sample data below. It includes a tie on purpose (Bravo and Charlie in West). The matrix has Year on columns, filtered to 2026, because % of Grand Total in Flexa Tables needs a field in Columns as well as Rows.

RegionProductRevenueRank (ties skip)Running total in region% of region% of grand total
WestAlpha500150031.3%16.9%
WestBravo400290025.0%13.6%
WestCharlie40021,30025.0%13.6%
WestDelta30041,60018.8%10.2%
EastEcho600160044.4%20.3%
EastFoxtrot45021,05033.3%15.3%
EastGolf30031,35022.2%10.2%

Figure 2. Sample data used in the examples: Revenue by Region and Product, with a tie in West (Bravo and Charlie).

The grand total is 2,950. The approaches agree on rank and shares. They differ in who has to write the calculation, who can change it later, and how the tied rows are treated in the running total (section 6).

WEST · EACH BAR SPANS THE REGION TOTAL OF 1,600

1Alpha· 500 = 31.3% of West · running total 500

2Bravo· 400 = 25.0% of West · running total 900

2Charlie· 400 = 25.0% of West · running total 1,300

4Delta· 300 = 18.8% of West · running total 1,600

Added by the rows above This product Rest of West

Figure 3. The West rows from Figure 2. The width of the blue part is the product's share of the region, and the bar ends where the running total stands. Bravo and Charlie tie at rank 2. Sample data.

3. Approach 1: DAX measures

WORKS IN ANY VISUAL

The default pattern is one measure per calculation. Each one hard-codes the grouping it works within, here Region and Product:

Rank in Region =
IF (
    HASONEVALUE ( Sales[Product] ),
    RANKX ( ALLSELECTED ( Sales[Product] ), [Revenue], , DESC, SKIP )
)

Running Total in Region =
VAR _rank = [Rank in Region]RETURN
    IF (
        HASONEVALUE ( Sales[Product] ),
        CALCULATE (
            [Revenue],
            FILTER ( ALLSELECTED ( Sales[Product] ), [Rank in Region] <= _rank )
        )
    )

% of Region =
DIVIDE (
    [Revenue],
    CALCULATE ( [Revenue], ALLSELECTED ( Sales[Product] ) )
)

% of Grand Total =
DIVIDE (
    [Revenue],
    CALCULATE ( [Revenue], ALLSELECTED ( Sales[Region], Sales[Product] ) )
)

A few details decide whether these behave:

ALLSELECTED keeps slicer selections, so the shares add up to what the reader sees. ALL ignores slicers and divides by the full model total.

The HASONEVALUE guard returns BLANK on subtotal and total rows. Without it, a total row would be ranked against the products beneath it.

RANKX skips after a tie by default (1, 2, 2, 4). Pass DENSE to get 1, 2, 2, 3.

The running total as written gives tied rows the same value: Bravo and Charlie both show 1,300, because both have a rank of 2 and the filter keeps rank 2 or better. Splitting ties needs a tie-breaker such as a second sort key.

This approach is explicit and easy to debug: one cell, one named measure, usable in any visual. The cost is the count and the lock-in. That is four measures for Revenue, so twelve once Cost and Profit need the same treatment (a calculation on the example, not a benchmark). Each measure also hard-codes Region and Product. If a reader wants the same ranking by Product within Month, someone edits DAX and republishes.

4. Approach 2: visual calculations

CREATED IN EDIT MODE

Power BI has its own answer to this. A visual calculation is a DAX calculation defined and run on a visual instead of being added to the semantic model. It refers to what is already on the visual, so it does not depend on filter context, and it knows the visual's structure. For the same matrix:

Running Total in Region = RUNNINGSUM ( [Revenue], HIGHESTPARENT )

% of Grand Total = DIVIDE ( [Revenue], COLLAPSEALL ( [Revenue], ROWS ) )

% of Region = DIVIDE ( [Revenue], COLLAPSE ( [Revenue], ROWS ) )

RUNNINGSUM with HIGHESTPARENT starts the running total again for each region. Ranking uses the RANK function, which takes the same SKIP and DENSE tie options as RANKX and can be reset at the parent level so the rank stays inside each region. Each calculation is a single line, and none of them names the Sales table or its relationships.

It is a fair alternative to a measure. Two limits matter for who owns the view:

The report author creates it. Visual calculations are added while editing the report. Someone reading a published report cannot add a running total or a rank of their own.

It lives on one visual. A calculation is not a model object, so a card, a chart or another matrix cannot reuse it. Those need their own copy, or a measure.

That makes visual calculations a good fit when one author builds one matrix and decides which calculations it carries.

5. Approach 3: Quick Calculations in Flexa Tables

PICKED PER VALUE COLUMN

Flexa Tables, a Microsoft-certified custom visual on AppSource, has a tab called Quick Calculations. It turns a value column into a share, a running total, a rank or a movement against a baseline. The choice is made per value column, so one table can show an amount in one column and a share in the next, with no second measure in the model. The Flexa Tables documentation lists each option.

To set it up on the sample matrix:

1Build a table with Region and Product in Rows, Year in Columns and Revenue in Values.
2Open Analytics › Quick Calculations. There is one line per value column.
3Pick the calculation from the selector at the right-hand end of the line.
4Set the choices that calculation brings with it. Rank adds a method and a direction.
Variance
Simulations
Quick Calculations
Summary Type

%Quick Calculations 1

Show a value as a percentage, running total, rank or difference.

Sum of Revenue
Absolute ⌃
Absolute ✓
% Of Grand Total
% Of Row Total →
% Of Column Total ↓
Running Total ↓ Down
Running Total → Across
Rank ↓ Down

Figure 4. The Quick Calculations tab with the calculation list open on a value column. Illustration based on the Flexa Tables interface.

DEMOSee every calculation run on one value column. Watch the Quick Calculations demo →

Each calculation reads the table the way the reader sees it: down a group of sibling rows or along the columns of a row, after the active filters. What each one returns in the sample matrix:

Quick CalculationWhat it returns in the sample matrix
Rank ↓ DownThe product's position by Revenue within its region, largest to smallest by default, with a choice of how ties are numbered (section 6)
Running Total ↓ DownRevenue added up in the order shown, so each row adds the ones above it and the last row of each region arrives at that region's total
% of Parent Row ↓The product's share of its own region (Alpha is 31.3% of West). It needs a row hierarchy of at least two fields
% of Grand TotalThe product's share of the whole table (Alpha is 16.9% of 2,950). It needs fields in both Rows and Columns

There are also % of Row Total → and % of Column Total ↓, a → Across direction for Rank and Running Total, and Diff From, which compares a value with the previous or first row. Diff From is covered in How to Show Variance in a Power BI Table. A percentage can also print the amount beside the ratio (Value + Percent).

GOOD TO KNOW

Running Total follows the displayed sort order, so re-sorting the table re-accumulates it, while a Rank does not move when you re-sort. A blank value carries the running figure forward rather than breaking the curve.

What this removes: the extra measure per calculation. Rank, running total and both shares come from one Revenue measure, and a second metric such as Cost gets the same options without new DAX. What it does not remove: the base measure and a sensible model underneath it. The calculations also live inside the visual, so a card or chart elsewhere in the report that needs the same rank still needs a measure or a visual calculation of its own. Flexa Tables works in the published report and does not need DAX for these calculations. For the pivoting side of the same visual, see pivot tables in Power BI.

FLEXA TABLES · 30-DAY FREE TRIAL

Rank, running total and % of total without a measure per calculation

Pick the calculation on the value column of your Power BI table. Install from Microsoft AppSource.

Start free trial on AppSource →See the demo

6. Ties, top 10 per group and the Total row

Three details decide whether a rank report can be trusted.

Ties. West has two products at 400. How they are numbered changes the numbers below them:

REVENUECOMPETITIONDENSEUNIQUE
500111
400222
400223
300434

The shaded rows are the tie.

Figure 5. The four West rows numbered three ways. Sample data.

Competition numbering (1, 2, 2, 4) is how Excel RANK and DAX RANKX number ties, and it is the default in RANKX. Dense (1, 2, 2, 3) is one keyword away in DAX. Unique numbering needs a tie-breaker in DAX, such as a second sort key. Flexa Tables offers all three as a method on the Rank line. Decide which one your readers expect before you publish: a "rank 3 or better" filter keeps three rows in West under Competition or Unique, and four under Dense.

Variance
Simulations
Quick Calculations
Summary Type

%Quick Calculations 1

Show a value as a percentage, running total, rank or difference.

Sum of Revenue

Competition ⌃
Competition ✓
Dense
Unique
Largest → Smallest ⌄
Rank ↓ Down ⌄

Figure 6. The Rank line in Quick Calculations with the three tie methods open. Illustration based on the Flexa Tables interface.

DEMOWatch the same tie answered three ways. See the Rank methods in the demo →

Running total on tied rows. A running total adds up in the order shown, so the tied rows get different values: 900 for Bravo and 1,300 for Charlie. The DAX measure in section 3 filters on rank instead of position, so it shows 1,300 on both. Neither is wrong, but they disagree, and a reader comparing two reports will notice.

Top 10 per group. The usual request is "the ten best products in each region", not "ten rows in total". The Top N filter in the Filters pane ranks one field across the visual rather than inside each region, so per-group top 10 in DAX means a rank measure like the one in section 3 plus a filter on it.

In Flexa Tables, set the value column to Rank and filter the Rank column header to 10 or less. Each rank is calculated within its own group, and the header filter keeps the rows whose printed number matches, so the filter keeps each region's top 10 rather than the top 10 rows of the table. One consequence is documented: the rows that survive the filter are not re-ranked or re-accumulated, so a Running Total column next to a filtered Rank still shows the figure from before the filter.

The Total row. A rank or a running total of a total is not a meaningful number, so Flexa Tables leaves it empty. The percentage modes fill in the grand-total row, while Running Total, Rank and Diff From leave it blank: a running total has already reached the full figure in the last row, and a rank has nothing to rank the total against.

RevenueRankRunning total% of grand total
Golf (last East row)30031,35010.2%
Total row2,950blankblankfilled in

Figure 7. What the Total row shows in the sample matrix: blank for Rank and Running total, filled in for a percentage mode. Sample data.

LIMIT

The DAX measures in section 3 return BLANK on the Total row through the HASONEVALUE guard. If your report needs a number there, it needs a different calculation, not a rank.

7. Which approach fits your report

DAX measures

CREATED BY

Model author

REUSABLE

In any visual

BEST FIT

Numbers that cards and charts share, with a stable grouping

Visual calculations

CREATED BY

Report author, in edit mode

REUSABLE

No, lives on one visual

BEST FIT

One matrix built and owned by one report author

Quick Calculations

CREATED BY

Picked on the value column inside the visual

REUSABLE

No, lives inside the visual

BEST FIT

Tables that need the same few calculations across many value columns

The approaches combine well. Keep a measure for any number a card or chart needs, and use Quick Calculations in the table where readers rank, accumulate and compare. For the comparison side of the same problem, see Calculation Groups vs Separate Measures for Variance in Power BI, and for the variance columns built into the visual, variance analysis in Power BI.

8. Related guides

9. FAQ

How do I rank within a group in Power BI?

Use RANKX over ALLSELECTED of the inner field, so the outer group's filter stays in place. In a visual calculation, use RANK and reset it at the parent level.

How do I get a running total that resets for each group?

In a visual calculation, use RUNNINGSUM with a reset such as HIGHESTPARENT. In a measure, add up the rows that sort at or before the current one inside the group.

What is the difference between % of parent total and % of grand total?

% of parent total divides a value by the total of its own group, such as a product's share of its region. % of grand total divides it by the total of the whole table.

How are ties handled in a Power BI rank?

RANKX skips after a tie by default, giving 1, 2, 2, 4. DENSE gives 1, 2, 2, 3. Unique numbering needs a tie-breaker such as a second sort key.

Does the Total row show a rank or a running total in Flexa Tables?

No. In Flexa Tables, Rank and Running Total leave the grand-total row empty, while the percentage modes fill it in.

facebooklinkedintwittermail