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
HaiVN
Helper III
Helper III

Measure : Calculate does not select right MAX ( date)

Dear all, 
I need your help on my DAX 
I write a measure: 
----
Total persons =
Var
   Total = CALCULATE(
      SUM('data'[value]),
      'data'[Date]=MAX('data'[Date]))
return
   if(Total>4, Total, "< 5")

------
'data'[Date] has 4 dates:

4. mars 2024
11. mars 2024
18. mars 2024
14. mai 2024

10. juni 2024

 

My problem is the measure choose " 4. mars 2024" for calculation , not "10. juni 2024" as I want! Can you help my to clarify what is problem with my measure ?

 

Thank you!

4 REPLIES 4
Anonymous
Not applicable

Hi @HaiVN ,

 

I am looking forward to your feedback if there is any update.

 

Please remember to update this thread if you have any progress.

 

Thank you for your understanding.

 

Best regards,

Joyce

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @HaiVN , aduguid, thank you for your prompt reply!
This works on my sample data according to my tests, please upload your pbix file for further testing if possible.

vyajiewanmsft_0-1723182842676.png

Best regards,

Joyce

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

aduguid
Super User
Super User

Try this measure 

Total persons =
VAR MaxDate = MAXX(ALL('data'[Date]), 'data'[Date])
VAR Total = CALCULATE(
    SUM('data'[value]),
    'data'[Date] = MaxDate
)
RETURN
    IF(Total > 4, Total, "< 5")

@aduguid Thanks for your help, but it does not work when I try the measure as you suggest. 
When I try to show the maxdate only i a card , ut shows correct. But when it is i the measure, it does not  works

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.