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
Jlbaenlo
Frequent Visitor

Extra column in table, populated by offseting by X months another existing column from this table

Hello,

I would need some guidance on the following problem

I have a table

Product - Country - Date - KPI1

A-C1-Jan2020- 60

A-C1-Feb2020-70

A-C1-Mar2020-50

I would like to add an extra column which would put for each Product-Country-Date the KPI1 of the previous month date for that same product-country (and blank if no record found)

Product - Country - Date - KPI1 - Newcol

A-C1-Jan2020- 60- Blank

A-C1-Feb2020-70- 60

A-C1-Mar2020-50-70

in the example above I put 60 in the new column as it was the value of the previous month, etc...

I need to formula generic enough so I can decide how many months back I want to take the value.

 

Many thanks,

BR,

Jean-Luc

4 REPLIES 4
Anonymous
Not applicable

Hi @Jlbaenlo ,

In my opinion,  @amitchandak 's method is the simplest and most efficient.

If he answered your question, please mark his post as a solution.

 

Best regards,

Eyelyn Qin

Greg_Deckler
Community Champion
Community Champion

@Jlbaenlo - You will need a true Date column or you will need an Index column or you will need a big nasty SWITCH statement in order to figure out your previous month. If Date column your previous month is:

Newcol =
  VAR __Product = [Product]
  VAR __Country = [Country]
  VAR __PreviousMonth = EOMONTH([Date],-1)
  VAR __PreviousDate = DATE(YEAR(__PreviousMonth),MONTH(__PreviousMonth),1))
  VAR __Previous = MAXX(FILTER('Table',[Product]=__Product && [Country]=__Country && [Date]=__PreviousDate),[KPI1]

 For Index and SWITCH, same basic thing just how you arrive at your "__PreviousDate"



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...
amitchandak
Super User
Super User

@Jlbaenlo , I am assuming date is date not month year, else create a date

a new column
sumX(filter(Table, [Product] =earlier([Product]) && [Country] = earlier([Country]) && eomonth([Date],0) =eomonth(earlier([Date]),-1)),[KPI1])

 

or

 

sumX(filter(Table, [Product] =earlier([Product]) && [Country] = earlier([Country]) && eomonth([Date],0) =eomonth(earlier([Date]),-1)),earlier([KPI1]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Many thanks, it worked brilliantly !

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors