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
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
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.