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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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