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
sam95
New Member

DAX Measure not giving correct result when I add conditions for dates.

I've got the following measure 

 

Test 2 (Manual) =
(COUNTROWS(FILTER('Treatments',
'Treatments'[Treatment Status] = "Completed" &&
Treatments[Treatment Date] <= [End Month 2]  &&
Treatments [Treatment Date] >= [Start Month 2])))
 
End Month 2 is 31/05/2023 23:59:59 and Start Month 2 is 01/05/2023 00:00:01
 
Start Month 2 and End Month 2 are calculated based on a slicer value, so for example if I select 21/06/2023, as my end date on the slicer, then Start and End Month 2 will be calculated based on these dax measures.
 
Start Month 2 = EOMONTH(MAX(Treatments[Treatment Date]), -2) + 1 + time(0,0,1)
End Month 2 = EOMONTH([End Month 1], -1) + time(23,59,59)
 
When I calculate Test 2 (Manual), it gives me a result of 13610 which is incorrect, it should be 2652. I'm not sure of what I am doing wrong, I already configured the card that displays the value so that it ignores the slicer and doesn't try to calculate it based on that, but the value is still wrong. What could I do to fix this?
 
 
2 REPLIES 2
Anonymous
Not applicable

Hi @sam95 ,

 

Please try:

Start Month 2 = EOMONTH ( MAX ( Treatments[Treatment Date] ), -2 ) + 1 + TIME ( 0, 0, 1 )
End Month 2 = EOMONTH(MAX(Treatments[Treatment Date]), -1) + TIME ( 23, 59, 59 )

 

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

devanshi
Helper V
Helper V

Startmonth 2 = DATE(YEAR(MAX([Date])), MONTH(MAX([Date]))  - 1, 1)
Endmonth 2 = EOMONTH(MAX([Date]), -2)

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.