Abstract, from a SQLBI article. Link to the original article on SQLBI.com click here https://sql.bi/817079. I just could recommend to read every single article from SQLBI, Alberto Ferrari XOR Marco Russo in full length. Below some key pattern and notes from my side as my personal abstract.

Pattern to compute ratios, when data is hidden by row-level security.

Pattern 1

Full row-level security

Example Measure

DAX
Pct over All =
DIVIDE (
    [Sales Amount],
    CALCULATE (
        [Sales Amount],
        ALL ( Customer )
    )
)

No row level security applied:

ContinentSales AmountPct over All
Australia10033.3%
Europe10033.3%
North America10033.3%
Total300Total

Row-level security: „Austrlia, Europe“

ContinentSales AmountPct over All
Australia10050.0%
Europe10050.0%
Total200100.0%

If that the goal to achieve, everything is fine.

Pattern 2

For any reason, you need „total sales“ in a row-level managed dataset. In that case it’s possible to materialize „total sales“ in a calculated table.

DAX
GrandTotalSales = ROW ( "Grand Total Sales", [Sales Amount] )
Grand Total Sales
300

This table will be not affected by row-level security setting.

To provide more granularity, calculated table could look like this.

DAX
SalesNoCustomer =
ADDCOLUMNS (
    SUMMARIZE (
        Sales,
        'Product'[ProductKey],
        'Date'[Date],
        Store[StoreKey]
    ),
    "Total Sales", [Sales Amount]
)

In that case it’s also necessary to create the propper relations.

Measure not affected by row-level security

DAX
Pct Not Secured =
DIVIDE (
    [Sales Amount],
    SUM ( SalesNoCustomer[Total Sales] )
)
ContinentSales AmountPct over AllPct Not Secured
Australia10050.0%33.3%
Europe10050.0%33.3%
Total200100.0%66.6%
Pattern 3

Partially exclude DimensionAttributes from row-level security.

Step 1: CalculatedTable, here CustomerAttributes

DAX
CustomerAttributes =
VAR T =
    SUMMARIZE (
        Customer,
        Customer[Country],
        Customer[State],
        Customer[Continent],
        Customer[Gender]
    )
RETURN
    ADDCOLUMNS ( T, "CustomerAttributeKey", ROWNUMBER ( T ) )
CountryStateContinentGenderCustomerAttributeKey
xxxxxxxxxxxx1
xxxxxxxxxxxx2
xxxxxxxxxxxx3

Step 2: Calculated Column, here SalesTable

DAX
CustomerAttributeKey =
LOOKUPVALUE (
    CustomerAttributes[CustomerAttributeKey],
    CustomerAttributes[Country],    RELATED ( Customer[Country] ),
    CustomerAttributes[State],      RELATED ( Customer[State] ),
    CustomerAttributes[Continent],  RELATED ( Customer[Continent] ),
    CustomerAttributes[Gender],     RELATED ( Customer[Gender] )
)

Step 3: Propagate, CalcCol from Step 2 to SalesNoCustomers

DAX
SalesNoCustomer =
ADDCOLUMNS (
    SUMMARIZE (
        Sales,
        Sales[CustomerAttributeKey],
        'Product'[ProductKey],
        'Date'[Date],
        Store[StoreKey]
    ),
    "Total Sales", [Sales Amount]
)

Step 4: In that case it’s also necessary to create the propper relations.

Step 5: Create measure(s)

DAX
Pct same gender =
DIVIDE (
    [Sales Amount],
    CALCULATE (
        SUM ( SalesNoCustomer[Total Sales] ),
        ALL ( CustomerAttributes ),
        VALUES ( CustomerAttributes[Gender] ),
     )
)
DAX
Pct same gender Generic =
DIVIDE (
    [Sales Amount],
    CALCULATE (
        [Sales Amount],
        ALL ( Customer ),
        VALUES ( Customer[Gender] )
    )
)
GenderSales AmountPct same gender Generic
Female300100.0%
— Australia10033.3%
— Europe10033.3%
— North America10033.3%
Male300100.0%
— Australia10033.3%
— Europe10033.3%
— North America10033.3%
Total600100.0%
GenderSales AmountPct same gender Generic
Female20066.6%
— Australia10033.3%
— Europe10033.3%
Male30066.6%
— Australia10033.3%
— Europe10033.3%
Total60066.6%