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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ronlolololo
Helper I
Helper I

MAXX Function Lookup

Hi folks, i am playing around the DAX and came across this issue. So the calculated column should return the case number of last day of the same county. It works fine for the first few rows but the stops changing after. But if I returned the date, it works prefect. Why would this happened? Please advised. Thank you!

ronlolololo_0-1595276673285.png

ronlolololo_0-1595277366522.png

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@ronlolololo 

please try this

Column = 
VAR _date=MAXX(FILTER('Table','Table'[countryFIPS]=EARLIER('Table'[countryFIPS])&&'Table'[State]=EARLIER('Table'[State])&&'Table'[date]<EARLIER('Table'[date])),'Table'[date])
return MAXX(FILTER('Table','Table'[countryFIPS]=EARLIER('Table'[countryFIPS])&&'Table'[State]=EARLIER('Table'[State])&&'Table'[date]=_date),'Table'[cases])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@ronlolololo 

please try this

Column = 
VAR _date=MAXX(FILTER('Table','Table'[countryFIPS]=EARLIER('Table'[countryFIPS])&&'Table'[State]=EARLIER('Table'[State])&&'Table'[date]<EARLIER('Table'[date])),'Table'[date])
return MAXX(FILTER('Table','Table'[countryFIPS]=EARLIER('Table'[countryFIPS])&&'Table'[State]=EARLIER('Table'[State])&&'Table'[date]=_date),'Table'[cases])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




v-kelly-msft
Community Support
Community Support

Hi  @ronlolololo ,

 

It is because your date column is ranking ascending,so using your expression can get the result you need,but if your date column is disordering,then you will get a wrong return,such as your case number.

The best solution is to create an index column.

I made a simple sample,pls see attached.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Greg_Deckler
Community Champion
Community Champion

@ronlolololo - Difficult to say. Please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.