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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
sudheerbolla
Helper II
Helper II

DAX function to populate present & prev term prem against only the latest record of same event codes

Hi Everyone,

@amitchandak , @Ashish_Mathur  , @danextian , @Ritaf1983 , @truptis , @lbendlin@Ritaf1983 ,@VilmarSch , @Kishore_KVN , @Ahmedx 

 

Please help in writing a DAX function to  populate present & prev term prem for Active policies against only the latest record of event code "policy_renewed" . A policy can have multiple event code of "policy_renewed" for same policy number as the customer renewed the policy for 2nd, 3rd, 4th term.

 

 

sudheerbolla_0-1689864665440.png

The following DAX Fuction is returning the values for all the "policy_renewed" event codes in a policy.

 

Current Term Prem =
if([Event Code] in {"policy_renewed"},
var md = [Transaction Date] var po = [Policy No] var te = [TERM]
var pd = CALCULATE(max(Data[Transaction Date]),ALL(Data),Data[Policy No]=po,Data[TERM]=te,Data[Transaction Date]<md, not Data[Event Code] in {"update_policy"})
var pdv = CALCULATE(sum(Data[Premium]),ALL(Data),Data[Policy No]=po,Data[TERM]=te,Data[Transaction Date]=pd)
return coalesce(pdv,[Premium])
))
 
Prev Term Renewed Prem =
if([Event Code] in {"policy_renewed"},
var po = [Policy No] var te = [TERM]
var pd = CALCULATE(max(Data[Transaction Date]),ALL(Data),Data[Policy No]=po,Data[TERM]<te,not Data[Event Code] in {"update_policy"})
var pdv = CALCULATE(sum(Data[Premium]),ALL(Data),Data[Policy No]=po,Data[Transaction Date]=pd)
return coalesce(pdv,[Current Term Prem])
))
 
How to modify the above code to populate the values for only the latest record "policy_renewed" or policy with record "policy_renewed" which has maximum Term for a given policy which is "Active" only.

 

Sample Data is in the link below

https://www.dropbox.com/scl/fi/49t01pcoxin0atljxoreq/data-Copy.xlsx?rlkey=rt0uviht1eu01x82dq2jiieha&...

 

 

 

 

 

0 REPLIES 0

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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