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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
awff
Helper III
Helper III

Creating a latest occurrence column

Hello fellow PBI'ers,

 

I am hoping to create a calculated column which identifies the latest occurrence with each account based on a few criterias. The result is as per the "Desired_Result" column in the mock table below:

 

Task:

  • For each account, Identify the latest maintenance occurrence by end date for each product. The result should be a string.

 

AccountNameEndDate  FamilyProductDesired_Result
Account 11-Jan-22MaintenanceALatest
Account 11-Mar-21MaintenanceA 
Account 11-Jul-22SoftwareA 
Account 21-Apr-20SoftwareB 
Account 21-Apr-22SoftwareC 
Account 31-Sep-21MaintenanceCLatest
Account 41-Sep-22MaintenanceA 
Account 41-Nov-22MaintenanceALatest
Account 41-Jan-21MaintenanceBLatest
Account 41-Aug-20SoftwareC 
Account 41-Aug-20MaintenanceCLatest

 

Would anyone be able to assist with this? I've tried the common SWITCH(TRUE() method but i can't seem to break it down to an products per account level...

 

Thanks!

1 ACCEPTED SOLUTION
FarhanAhmed
Community Champion
Community Champion

Try this

 

 

_Latest Result Column= 

Var Acc = 'Latest Occurence'[AccountName]
Var Pro = 'Latest Occurence'[Product]
Var dt = CALCULATE(MAX('Latest Occurence'[EndDate  ]),FILTER('Latest Occurence','Latest Occurence'[AccountName]=Acc && 'Latest Occurence'[Product]=Pro && 'Latest Occurence'[Family]="Maintenance"))

RETURN
IF(dt='Latest Occurence'[EndDate  ] && 'Latest Occurence'[Family]="Maintenance","Latest","")

 







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

Proud to be a Super User!




View solution in original post

3 REPLIES 3
awff
Helper III
Helper III

Amazing, thank you both @Jihwan_Kim  & @FarhanAhmed !  Both measures work as it should and has saved my hair. True life saver 🙂

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Picture2.png

 

Desired Result CC =
IF (
NOT ( Data[Family] = "Maintenance" ),
BLANK (),
SWITCH (
TRUE (),
VAR currentaccountname = Data[AccountName]
VAR currentproduct = Data[Product]
VAR newtable =
FILTER (
Data,
Data[AccountName] = currentaccountname
&& Data[Product] = currentproduct
&& Data[Family] = "Maintenance"
)
VAR maxdate_newtable =
MAXX ( newtable, Data[EndDate] )
RETURN
Data[EndDate] = maxdate_newtable, "Latest"
)
)


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

Click here to schedule a short Teams meeting to discuss your question.
FarhanAhmed
Community Champion
Community Champion

Try this

 

 

_Latest Result Column= 

Var Acc = 'Latest Occurence'[AccountName]
Var Pro = 'Latest Occurence'[Product]
Var dt = CALCULATE(MAX('Latest Occurence'[EndDate  ]),FILTER('Latest Occurence','Latest Occurence'[AccountName]=Acc && 'Latest Occurence'[Product]=Pro && 'Latest Occurence'[Family]="Maintenance"))

RETURN
IF(dt='Latest Occurence'[EndDate  ] && 'Latest Occurence'[Family]="Maintenance","Latest","")

 







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

Proud to be a Super User!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors