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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Including a date filter in a DAX measure

Hi all
 
I am trying to filter a sum of expenses by the item. I have done the following:
 
= CALCULATE(SUM(costofsales[Cost of Sales Expense]), FILTER(costofsales,costofsales[Cost of Sales Item]="Wages - Trainers Training Delivery (Contract)" || costofsales[Cost of Sales Item]="Training - Venue Hire" || costofsales[Cost of Sales Item]="Training - Resources & Printing" || costofsales[Cost of Sales Item]="Training - Accommodation" || costofsales[Date] > DATE(2021,5,31)))
 
It is providing me with the incorrect answer. 
I need the filter to contain all of the above sales items but only include those that have a date after 31 May 21. 
 
Any assistance would be great. 
Thanks. 
 
Karen
2 ACCEPTED SOLUTIONS
Jos_Woolley
Solution Sage
Solution Sage

Hi,

Measure =
CALCULATE (
    SUM ( costofsales[Cost of Sales Expense] ),
    costofsales[Cost of Sales Item]
        IN {
        "Wages - Trainers Training Delivery (Contract)",
        "Training - Venue Hire",
        "Training - Resources & Printing",
        "Training - Accommodation"
    },
    costofsales[Date] > DATE ( 2021, 5, 31 )
)

Regards

View solution in original post

Have you tried combining NOT with IN?

Regards

View solution in original post

8 REPLIES 8
Jos_Woolley
Solution Sage
Solution Sage

Hi,

Measure =
CALCULATE (
    SUM ( costofsales[Cost of Sales Expense] ),
    costofsales[Cost of Sales Item]
        IN {
        "Wages - Trainers Training Delivery (Contract)",
        "Training - Venue Hire",
        "Training - Resources & Printing",
        "Training - Accommodation"
    },
    costofsales[Date] > DATE ( 2021, 5, 31 )
)

Regards

Anonymous
Not applicable

Hi Jos Thank you. I knew it would be something simple. 

Appreciate your prompt reply. 😀

 

Sure! You're very welcome!

 

Cheers

Anonymous
Not applicable

Hi Jos

 

IRT my query above, how do I do "does not contain" those fields? Instead of the IN is there another function I use? I have been looking and trying different things but I haven't got it. Are you able to help me out? 

Have you tried combining NOT with IN?

Regards

Anonymous
Not applicable

Thank you @Jos_Woolley Tried that and it worked like a charm. Appreciate your guidance with that one. 

Cheers

Karen

Great stuff, glad to know! Cheers, Karen.

Jos

Anonymous
Not applicable

Yes, but I think I put them in the wrong place/order. I will have another go at that and see how I go. Thank you for the push in the right direction. 

Cheers

Karen

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.