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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

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
v-cgao-msft
Community Support
Community Support

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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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

Top Kudoed Authors