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
flyfisher63
New Contributor

Add custom column to existing table by offsetting rate column by 1 year

I have table in BI that has all our clients data and I am having a hard time creating a column called Prior Year Rate.

 

I have the following table except for the Prior Year Rate.

 

The 1st 3 columns are from the dataset, I added Expected Renewal Date as a calculated column of Expiration Date +1.

 

I have tried to add the Prior Year Rate but cannot find a way to do it. Its probably a simple solutions that is just escaping me.

 

Thanks for any help

 

PolicyholderEffective DateExpiration DateExpected Renewal DateCurrent Year RatePrior Year Rate
ABC Co1/1/202412/31/20241/1/202556.24 
ABC Co1/1/202512/31/20251/1/202660.3556.24
 
3 REPLIES 3
Greg_Deckler
Esteemed Contributor III

@flyfisher63 Try this:

Prior Year Rate Measure =
  VAR __PolicyHolder = MAX( 'Table'[PolicyHolder] )
  VAR __Date = MAX( 'Table'[Effective Date] )
  VAR __PreviousDate = 
    MAXX( 
      FILTER( 
        ALL( 'Table' ), 
        [Policyholder] = __Policyholder &&
        [Effective Date] < __Date 
      ), 
      [Effective Date] 
    )
  VAR __Result = 
    MAXX( 
      FILTER( 
        ALL( 'Table' ), 
        [Policyholder] = __Policyholder &&
        [Effective Date] = __PreviousDate 
      ), 
      [Current Year Rate] 
    )
RETURN
  __Return

 

As a calculated column:

Prior Year Rate Measure =
  VAR __PolicyHolder = [PolicyHolder]
  VAR __Date = [Effective Date]
  VAR __PreviousDate = 
    MAXX( 
      FILTER( 
        ALL( 'Table' ), 
        [Policyholder] = __Policyholder &&
        [Effective Date] < __Date 
      ), 
      [Effective Date] 
    )
  VAR __Result = 
    MAXX( 
      FILTER( 
        ALL( 'Table' ), 
        [Policyholder] = __Policyholder &&
        [Effective Date] = __PreviousDate 
      ), 
      [Current Year Rate] 
    )
RETURN
  __Return


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...
lbendlin
Esteemed Contributor III

Please specify if you want that as Power Query code, as a calculated column, or as a measure.

samratpbi
Contributor III

Hi, As @Greg_Deckler mentioned, you can create the measure or a calculated column. In adition, if you need to have previous row value simply in a visual, then you can use Visual Calculation also.

samratpbi_0-1760046855708.png

 

in the visual calculation, you can use PREVIOUS function.

samratpbi_1-1760046969996.png

 

Hope this helps.

If this helps to resolve your problem, then please mark it as solution.

Thanks - Samrat

Helpful resources

Announcements
Users online (9,584)