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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
mshaikh
Regular Visitor

MS - Conditional Total

Hi

 

I am looking for conditional sales total formula using following condition. Please find attached document for reference.

 

Complete_Date <= filter date  Filter date is between 2018-03-25 and 2018-03-31

Complete Percent = 100

Salesrep between SP1 and SP2

Code = Sales

 

Expected result = 2800

 

Can someone please provide suitable formula which work even after changing filter.

 

Thanks in advance,

 

MS

Sample.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @mshaikh,

 

When you use ALLSELECTED function in filter who already used ALL function, it will ignore filter effect which allselected provide.

For this scenario, please use VAR function to define selected value list outside of filter which used ALL function.

Measure =
VAR _SPerson =
    ALLSELECTED ( Table[Sales Person] )
VAR _SCode =
    ALLSELECTED ( Table[Code] )
RETURN
    CALCULATE (
        SUM ( Table[Amount] ),
        FILTER (
            ALL ( Table ),
            [Contract_Complete Date] <= MIN ( Calendar[Date] )
                && [Complete_Percent] = 100
                && [Sales Person] IN _SPerson
                && [Code] IN _SCode
        )
    )

Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT

 

Regards,

Xiaoxin Sheng

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

HI @mshaikh,

 

You can try to use below measure if it works for your requirement:

Measure =
CALCULATE (
    SUM ( Table[Amount] ),
    FILTER (
        ALLSELECTED ( Table ),
        [Contract_Complete Date] <= MIN ( Calendar[Date] )
            && [Complete_Percent] = 100
            && [Sales Person] IN ALLSELECTED ( Table[Sales Person] )
            && [Code] IN ALLSELECTED ( Table[Code] )
    )
)

 

If above not help, please share some sample data for test.

 

Regards,

Xiaoxin Sheng

Hi

 

Thanks for the formula.  Salesperson IN ALLSELECTED is not working with slicer. However when we manully add Salesperson code in measure it works. Please have a look at attached result set for reference.

 

 

Hi

 

Thanks for the formula.  Salesperson IN ALLSELECTED is not working with slicer. However when we manully add Salesperson code in measure it works. Please have a look at attached result set for reference.                Thanks,  MS

 

Sample1.png

 

 

 

Anonymous
Not applicable

HI @mshaikh,

 

When you use ALLSELECTED function in filter who already used ALL function, it will ignore filter effect which allselected provide.

For this scenario, please use VAR function to define selected value list outside of filter which used ALL function.

Measure =
VAR _SPerson =
    ALLSELECTED ( Table[Sales Person] )
VAR _SCode =
    ALLSELECTED ( Table[Code] )
RETURN
    CALCULATE (
        SUM ( Table[Amount] ),
        FILTER (
            ALL ( Table ),
            [Contract_Complete Date] <= MIN ( Calendar[Date] )
                && [Complete_Percent] = 100
                && [Sales Person] IN _SPerson
                && [Code] IN _SCode
        )
    )

Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.