Skip to content

Ratios, visual totals, and rankings

Before writing a percentage, finish this sentence: "this numerator divided by which population, under which retained filters?"

All-product share

Revenue Share All Products =
DIVIDE ( [Revenue], [All Products Revenue] )

At unrestricted product rows, Laptop is 8000 / 9500 = about 84.21%. Under North/Laptop, it is 3000 / 4100 = about 73.17% because Region is retained and product/category filters are removed.

Removing only ProductName would not necessarily remove a Category filter. This library deliberately removes the whole DimProduct table for its all-product denominator.

Selected-product share

Revenue Share Selected Products =
DIVIDE (
    [Revenue],
    CALCULATE ( [Revenue], ALLSELECTED ( DimProduct ) )
)

ALLSELECTED supports a visual-total comparison by retaining applicable outer selection context while removing row/column grouping filters. It is not a synonym for ALL or REMOVEFILTERS, and nested iterators can make its behavior more subtle.

Exercise: put ProductName on matrix rows and select Category = Accessories in a slicer. Selected shares are Mouse 800 / 1500 and Keyboard 700 / 1500. All-product shares still use 9500. Repeat under North and explain the denominator rather than assuming a fixed total.

A DAX query and a report visual need equivalent outer/filter context before their ALLSELECTED results can be compared. The unrestricted product query uses the all-product measure to keep its reference expectation unambiguous.

Dense rank with a meaningful total

Product Revenue Rank =
IF (
    ISINSCOPE ( DimProduct[ProductName] ),
    RANKX (
        ALLSELECTED ( DimProduct[ProductName] ),
        [Revenue],
        ,
        DESC,
        DENSE
    )
)

With no product selection, Laptop ranks 1, Mouse 2, Keyboard 3. The rank is deliberately BLANK at a total where ProductName is not in scope. RANKX visits the selected product names and evaluates the Revenue measure under each product context. Names are unique in this tiny model.

For production, choose the ranking entity/key, tie behavior, precision, blank treatment, and selection scope explicitly. Floating-point values can create unexpected comparisons; use appropriate numeric types/rounding where the business contract requires it.

Done when: you can explain a changed rank under a region/product selection and why grand-total rank is suppressed. References: ALLSELECTED, RANKX, ISINSCOPE.