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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
RainyClouds
New Member

Need help with DAX for percentage of filtered total with a twist

Hello all,

 

I'm trying to calculate a couple of measures in DAX using this dummy set of data from the table below (I cannot provide real data due to the nature of the project):

SalesPersonDatePaymentTypeLocationCategoryTransactionFlagAmount
Daisy11-JanCashMetroDongle010
Daisy11-JanCashRegionalWidget 15
Daisy11-JanCardMetroWidget1100
Daisy10-JanCashMetroWidget 12
Daisy10-JanCashRegionalWidget117
Daisy10-JanCardMetroDongle0120
Dean11-JanCashMetroDongle011
Dean11-JanCashRegionalWidget016
Dean11-JanCardMetroWidget0110
Dean10-JanCashMetroWidget013
Dean10-JanCashRegionalWidget018
Dean10-JanCardMetroDongle0130
Gillian11-JanCashMetroDongle09
Gillian11-JanCashRegionalWidget014
Gillian11-JanCardMetroWidget190
Gillian10-JanCashMetroWidget018
Gillian10-JanCashRegionalWidget019
Gillian10-JanCardMetroDongle080
Gibbo11-JanCashMetroDongle020
Gibbo11-JanCashRegionalWidget021
Gibbo11-JanCardMetroWidget 140
Gibbo10-JanCashMetroWidget030
Gibbo10-JanCashRegionalWidget08
Gibbo10-JanCardMetroDongle 105

*Note that in the table above, the TransactionFlag can have values of 1 (for true), 0 (for false), or blank (for not applicable).

 

The two measures are for Flagged Transaction Amount (those where TransactionFlag = 1) as a percentage of a SalesPerson's total Amounts; and then Flagged Transaction Amount as a percentage of all SalesPerson's total amounts who have a flagged transaction. I will also want to be able to slice the report by all dimensions. It is important that all of a SalesPerson's amounts are included in the total if and only if they have a flagged transaction in whatever slice has been selected.

 

So effectively I want to be able to get to a table like this:

SalesPerson  Date  PaymentType  Location  Category  Amount  Flagged Amount as a % of SalesPerson Total Amount  Flagged Amount as a % of All SalesPerson with FlaggedTransaction Total Amount  
Daisy11-JanCardMetroWidget10080.0042.02
Daisy10-JanCashRegionalWidget1711.4111.41
Gillian11-JanCardMetroWidget9079.65

37.82

 

 

And like this:

SalesPerson  PaymentType  Category  Amount  Flagged Amount as a % of SalesPerson Total Amount  Flagged Amount as a % of All SalesPerson with FlaggedTransaction Total Amount  
DaisyCardWidget11779.5943.66
GillianCardWidget9074.3833.58

 

Can anyone help me with the DAX for these measures? I'm not really even sure where to start. Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @RainyClouds,

 

You can use following measures to achieve your requirement, it will dynamic changes based on category fields:

% of SalePerson =
DIVIDE (
    SUM ( Sales[Amount] ),
    CALCULATE (
        SUM ( Sales[Amount] ),
        ALLSELECTED ( Sales ),
        VALUES ( Sales[SalesPerson] )
    ),
    -1
)

% of ALL SalePerson =
DIVIDE (
    SUM ( Sales[Amount] ),
    CALCULATE ( SUM ( Sales[Amount] ), ALLSELECTED ( Sales ) ),
    -1
)

 

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @RainyClouds,

 

You can use following measures to achieve your requirement, it will dynamic changes based on category fields:

% of SalePerson =
DIVIDE (
    SUM ( Sales[Amount] ),
    CALCULATE (
        SUM ( Sales[Amount] ),
        ALLSELECTED ( Sales ),
        VALUES ( Sales[SalesPerson] )
    ),
    -1
)

% of ALL SalePerson =
DIVIDE (
    SUM ( Sales[Amount] ),
    CALCULATE ( SUM ( Sales[Amount] ), ALLSELECTED ( Sales ) ),
    -1
)

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.