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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Sum Value Over Relative Date Range

Hello,

 

I have a table like this:

WorkOrderWhseComponentItemNumberQtyIssuedQtyCommittedWODueDate_CCOrderStatus
008332200000-2016163001/5/2023C
HZ152W100000-201616101/16/2023C
HY371-200000-201616301/20/2023C
HX400-100000-2016160101/30/2023F
HX943-100000-201616202/9/2023C
HY201-200000-201616012/15/2023F
HY732W100000-201616012/16/2023F
HY582-200000-201616023/10/2023F
HW992-100000-201616024/14/2023F
HZ948-100000-201616025/2/2023F
HX675-100000-201616015/17/2023F
HX678-900000-201616018/17/2023F
HX672-300000-2016160110/19/2023F
HX677-700000-2016160111/11/2023F

I need to sum the QTYCommited where the Orderstatus = "F" & the WODueDate is within the last two months, or within the next 3 months. How would this be written? 

I came up with this -

TotalNeededforCommit2 = CALCULATE(SUM(WO2_WorkOrderMaterialDetail[QtyCommitted]), WO2_WorkOrderMaterialDetail[OrderStatus] = "F" && WO2_WorkOrderMaterialDetail[WODueDate_CC] >= DATEADD(Today(), -2, MONTH) &&  WO2_WorkOrderMaterialDetail[WODueDate_CC] <= DATEADD(Today(), 6, MONTH))

but I'm getting the error "A function DATEADD has been used in a true/false expression that is used as a table filter expression. This is not allowed."

What other dax function should I be using for this? Am I missing something? 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

The return value of DATEADD() is a table with a single column. You are using a date to compare with a table.

DATEADD

 

Try this:

TotalNeededforCommit2 = 
CALCULATE (
    SUM ( WO2_WorkOrderMaterialDetail[QtyCommitted] ),
    WO2_WorkOrderMaterialDetail[OrderStatus] = "F"
        && WO2_WorkOrderMaterialDetail[WODueDate_CC] >= EDATE(TODAY(),-3)
        && WO2_WorkOrderMaterialDetail[WODueDate_CC] <= EDATE(TODAY(),6)
)

EDATE

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

The return value of DATEADD() is a table with a single column. You are using a date to compare with a table.

DATEADD

 

Try this:

TotalNeededforCommit2 = 
CALCULATE (
    SUM ( WO2_WorkOrderMaterialDetail[QtyCommitted] ),
    WO2_WorkOrderMaterialDetail[OrderStatus] = "F"
        && WO2_WorkOrderMaterialDetail[WODueDate_CC] >= EDATE(TODAY(),-3)
        && WO2_WorkOrderMaterialDetail[WODueDate_CC] <= EDATE(TODAY(),6)
)

EDATE

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Anonymous
Not applicable

Thank you much!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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