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
vwiles84
Helper III
Helper III

Calculate measure with If Statement

I am trying to write a calculation that if the Year is 2023 and the months are March and April, don't include those numbers in the sum.  If have the filter working for the month but need to include code to only exclude the month if it is a particular year (2023).  Can you assist? 

 

Here is the measure to exlude the 2 months. I just need to be able to only exclude these months IF it's 2023. I can't quite get it. 

 

Donation QTY Minus MarApril = CALCULATE(SUM(RPT_ITM_D[F64]),FILTER(RPT_ITM_D,RPT_ITM_D[F1034]=3), FILTER('Date Table', 'Date Table'[Month Name] <> "April"), FILTER('Date Table', 'Date Table'[Month Name] <> "March"))
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @vwiles84 ,
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:

vheqmsft_0-1709617016634.png

Create a measure

Donation QTY Minus MarApril = 
CALCULATE(
    SUM('Table'[Value]),
    FILTER(
        'Table',
        'Table'[Year] <> 2023 || ('Table'[Month]<> "April" && 'Table'[Month]<>"March")
    )
)

Final output

vheqmsft_1-1709617060678.png

Best regards,

Albert He

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @vwiles84 ,
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:

vheqmsft_0-1709617016634.png

Create a measure

Donation QTY Minus MarApril = 
CALCULATE(
    SUM('Table'[Value]),
    FILTER(
        'Table',
        'Table'[Year] <> 2023 || ('Table'[Month]<> "April" && 'Table'[Month]<>"March")
    )
)

Final output

vheqmsft_1-1709617060678.png

Best regards,

Albert He

 

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

 

JamesFR06
Resolver IV
Resolver IV

Hi,

First of all store the year value on a vairable

Var ActivYear=selectedvalue(date(year)

var DonationQty=CALCULATE(SUM(RPT_ITM_D[F64]),RPT_ITM_D[F1034]=3)

var result= If(ActivYear=2023,

calculate(DonationQty,NOT ('Date Table'[Month Name]  in {"April","March"}),

DonationQty)

Return

result

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors