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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
JL0101
Helper II
Helper II

How to create a sumx with 2 filter conditions

I have the following code

 

PivCouplers-Male =

SUMX(
              FILTER(
              PivCouplers,
                          CONTAINSSTRING(('PivCouplers'[shape_code]),"m")),[SumOfShapeCode])

 

How do I add an aditional Filter below CONTAINSSTRING to include something along the lines of AND take the latest model, i.e. what is the syntax for 2 filters or more on the SUMX ?

 

Thanks

1 ACCEPTED SOLUTION

Hi @JL0101 

 

Return is missing from your formula, so please try this:

VAR MaxRevision =
    MAX ( 'PivCouplers'[A-schedule_revision_numbers] )
RETURN
    SUMX (
        FILTER (
            PivCouplers,
            CONTAINSSTRING ( ( 'PivCouplers'[shape_code] ), "m" )
                && 'PivCouplers'[A-schedule_revision_numbers] = MaxRevision
        ),
        [SumOfShapeCode]
    )

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
JL0101
Helper II
Helper II

JL0101_0-1719395632424.png

 

The syntax for 'SUMX' is incorrect. (DAX(VAR MaxRevision = MAX('PivCouplers'[A-schedule_revision_numbers])SUMX( FILTER( PivCouplers, CONTAINSSTRING(('PivCouplers'[shape_code]),"m") && 'PivCouplers'[A-schedule_revision_numbers] = MaxRevision ),[SumOfShapeCode] ))).

Hi @JL0101 

 

Return is missing from your formula, so please try this:

VAR MaxRevision =
    MAX ( 'PivCouplers'[A-schedule_revision_numbers] )
RETURN
    SUMX (
        FILTER (
            PivCouplers,
            CONTAINSSTRING ( ( 'PivCouplers'[shape_code] ), "m" )
                && 'PivCouplers'[A-schedule_revision_numbers] = MaxRevision
        ),
        [SumOfShapeCode]
    )

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

barritown
Super User
Super User

Hi @JL0101,

I guess you should try using "&&" as AND, like: SUMX ( FILTER ( Table, CONDITION_1 && CONDITION_2 ), [Measure or Column] ).

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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