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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

How to Determine latest occurrence of value?

Hi there, 
I have table with Id, Date and Amount. 

slav84_1-1621499995319.png

 

As you can see the OrderId repeats sometimes and what i need to find is latest occurance. For example, OrderId 10005 happens 3 times and i need to mark the last accourance. So ultimately in the same table i would like to get something like this:

 

OrderIdDateAmountOccuranceLastOccurance
100011/5/202151Yes
100021/6/202161Yes
100031/7/202171No
100031/8/2021102Yes
100041/9/202141Yes
100051/10/202171No
100051/11/202142No
100051/12/2021103Yes
100061/13/2021631Yes
100071/14/2021431Yes
100081/15/2021231Yes
100091/16/2021561No
100091/17/2021602Yes
100101/18/2021431Yes
100111/19/2021211Yes

 

This will tell me if the value for that order is last or not. 
How do i do this using Dax?

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @Anonymous 

Create a calculated column:

 

Last occurence = 
VAR lastDate_ = CALCULATE(MAX(Table1[Date]), ALLEXCEPT(Table1, Table1[OrderId]))  
RETURN
IF(lastDate_ = Table1[Date], "Yes", "No")

 

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below picture and the sample pbix file's link down below.

I tried to create a measure for a visualization.

All measures are in the sample pbix file.

 

Picture2.png

 

https://www.dropbox.com/s/2uur383m43k2t18/slav84.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

AlB
Community Champion
Community Champion

Hi @Anonymous 

Create a calculated column:

 

Last occurence = 
VAR lastDate_ = CALCULATE(MAX(Table1[Date]), ALLEXCEPT(Table1, Table1[OrderId]))  
RETURN
IF(lastDate_ = Table1[Date], "Yes", "No")

 

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Anonymous
Not applicable

Thank you both. 
The answer @AlB provided is exactly what i was looking for. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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