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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
juhoneyighot
Helper III
Helper III

SUM , FIlter, Containsstring DAX Formula

Hello!

 

I have this sum dax formula with the following filters

0RevActTransactions2 = CALCULATE(
SUM('_Facts'[Amt])*-1,
FILTER(_Facts,CONTAINSSTRING(_Facts[LOOKUPLegacyTransType],"INVOICE")) &&
'_Facts'[FH_CurrentYN] = "Yes" &&
'_Facts'[FH_Type] = "28 Legacy AS Transactions" &&
'_Facts'[GLAccountCategory] = "400 SALES"
)

However, I have to add another filter CONTAINSSTRING(_Facts[LOOKUPLegacyTransType],"CREDIT MEMO" which is the same field where the "INVOICE" has been filtered.

 

Any suggestions how I could do the formula. I have done this but I get the incorrect result

0RevActTransactions2 = CALCULATE(
SUM('_Facts'[Amt])*-1,
FILTER(_Facts,CONTAINSSTRING(_Facts[LOOKUPLegacyTransType],"INVOICE" && CONTAINSSTRING(_Facts[LOOKUPLegacyTransType],"CREDIT MEMO"))) &&
'_Facts'[FH_CurrentYN] = "Yes" &&
'_Facts'[FH_Type] = "28 Legacy AS Transactions" &&
'_Facts'[GLAccountCategory] = "400 SALES"
)

1 ACCEPTED SOLUTION
Bibiano_Geraldo
Super User
Super User

Hi @juhoneyighot ,
The issue you're encountering is because the CONTAINSSTRING function is not properly combining both conditions in the FILTER function. When you use && inside CONTAINSSTRING, it doesn't work as expected because CONTAINSSTRING expects a single condition to evaluate, not multiple conditions combined with logical operators.

 

Here's the corrected version of your DAX formula:

RevActTransactions2 = CALCULATE(
    SUM('_Facts'[Amt]) * -1,
    FILTER(
        _Facts,
        (CONTAINSSTRING(_Facts[LOOKUPLegacyTransType], "INVOICE") || CONTAINSSTRING(_Facts[LOOKUPLegacyTransType], "CREDIT MEMO")) &&
        '_Facts'[FH_CurrentYN] = "Yes" &&
        '_Facts'[FH_Type] = "28 Legacy AS Transactions" &&
        '_Facts'[GLAccountCategory] = "400 SALES"
    )
)

 

 

View solution in original post

3 REPLIES 3
Bibiano_Geraldo
Super User
Super User

Hi @juhoneyighot ,
The issue you're encountering is because the CONTAINSSTRING function is not properly combining both conditions in the FILTER function. When you use && inside CONTAINSSTRING, it doesn't work as expected because CONTAINSSTRING expects a single condition to evaluate, not multiple conditions combined with logical operators.

 

Here's the corrected version of your DAX formula:

RevActTransactions2 = CALCULATE(
    SUM('_Facts'[Amt]) * -1,
    FILTER(
        _Facts,
        (CONTAINSSTRING(_Facts[LOOKUPLegacyTransType], "INVOICE") || CONTAINSSTRING(_Facts[LOOKUPLegacyTransType], "CREDIT MEMO")) &&
        '_Facts'[FH_CurrentYN] = "Yes" &&
        '_Facts'[FH_Type] = "28 Legacy AS Transactions" &&
        '_Facts'[GLAccountCategory] = "400 SALES"
    )
)

 

 

Greg_Deckler
Community Champion
Community Champion

@juhoneyighot Try:

0RevActTransactions2 = CALCULATE(
SUMX(,
  FILTER(
    _Facts, 
    CONTAINSSTRING(_Facts[LOOKUPLegacyTransType],"INVOICE") && 
    CONTAINSSTRING(_Facts[LOOKUPLegacyTransType],"CREDIT MEMO") &&
    '_Facts'[FH_CurrentYN] = "Yes" &&
    '_Facts'[FH_Type] = "28 Legacy AS Transactions" &&
    '_Facts'[GLAccountCategory] = "400 SALES"
  ),
  '_Facts'[Amt]
)*-1


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

juhoneyighot_0-1732201659161.png

@Greg_Deckler It doesnt show any value

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.