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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Newbie_1
Frequent Visitor

Exclude rows from sum based on condition

Hi everyone,

I am trying to achieve a measure that calculates the total of column 'value' but excludes certain rows based on multiple conditions because if I Calculate the total of the column, there will be some double counting. The double counting only occurs when the month is still open, and the columns through which this issue can be identified in are in Document type (if it's equal to SD)  and Purchase order Description (if it begins on an "@")Attach.PNG
The original table is much larger with other rows and columns but I have just attached the higligths.
For starters, I have created a measure (Month(Today)) so that PowerBI always knows which month it is, but that's how far I got when trying to use the CALCULATE and IF DAXs.

My problem is that Calculate is not compatible with TRUE/FALSE statements, i.e., (Month(Today)) and IF statements cannot refer to a column, only a measure, as far as I undestand.

 

What I need is an automate formula than can calculate the total of the value column but exclude any row of the total IF you're in the current (open month) and Document type = SD or Purchase Order Description starts with "@"
Is this possible or do I have to perform multiple steps? i.e. adding a new column to isolate the "@" or any other step?

The inverse would also be sufficient, namely sum all the rows in the Value column if current month = Month Number AND Docuemnt type = "SD" / Product Description order starts with "@" and I could just deduct this value from the total.

1 ACCEPTED SOLUTION

hi @Newbie_1 

Do you mean your Month Number column is text format,so just adjust the formula as below with VALUE Function

 

Measure =
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        Table,
        MONTH ( TODAY () ) = VALUE(Table[Month Number])
            && Table[Document Type] = "SD"
            && LEFT ( Table[Purchase Order Description], 1 ) = "@"
    )
)

 

 

Regards,

Lin

Community Support Team _ Lin
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

5 REPLIES 5
v-lili6-msft
Community Support
Community Support

hi  @Newbie_1 

 

You try this measure

Measure =
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        Table,
        MONTH ( TODAY () ) = Table[Month Number]
            && Table[Document Type] = "SD"
            && LEFT ( Table[Purchase Order Description], 1 ) = "@"
    )
)

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks a lot! This worked like a charm!

az38
Community Champion
Community Champion

Hi @Newbie_1 

create a measure

Total Value Measure = 
CALCULATE(SUM('Table'[Value]), ALL(Table), MONTH(TODAY()) = Table[Month Number], Table[Document Type] = "SD", LEFT(Table[Purchase Order Description], 1) = "@")

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Newbie_1
Frequent Visitor

Thank you for the effort, unfortunately this generated the error I have been facing before, namely that I get an error because DAX does not allow the comparison of Values of Interger with Values of type text. Probably it's my dataset that prohibits it but the solution below help me to mediate it!

hi @Newbie_1 

Do you mean your Month Number column is text format,so just adjust the formula as below with VALUE Function

 

Measure =
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        Table,
        MONTH ( TODAY () ) = VALUE(Table[Month Number])
            && Table[Document Type] = "SD"
            && LEFT ( Table[Purchase Order Description], 1 ) = "@"
    )
)

 

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.