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
sabeensp
Helper IV
Helper IV

Last 12 Month Extract

Hello,

 

I'm new to PBI. 

I have a table with many columns including Year and Month. I need to SUMMARIZE table into another table with only last 12 months data. We do not have DATE Dimmension in the model. Also this table does not have current month data, it has upto last month data. IN my current table max month is Oct. I need to just get Year and Month Going back to Nov 

Year   Month
2018  6

2018  6

2018  6

2018  6

2018  6

2018  7

2018  7

and so on

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Perhaps something like:

 

Table 1 = 
VAR __year = MAX('Table'[Year])
VAR __yearPrev = __year - 1
VAR __month = MAXX(FILTER('Table',[Year]=__year),[Month])
VAR __table = FILTER('Table',[Year] = __year || ([Year] = __yearPrev && [Month] > __month))
RETURN
SUMMARIZE(__table,[Year],[Month],"My Column",SUM([Value]))

Also, I feel that this link might come in handy for you:


https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



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...

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

Perhaps something like:

 

Table 1 = 
VAR __year = MAX('Table'[Year])
VAR __yearPrev = __year - 1
VAR __month = MAXX(FILTER('Table',[Year]=__year),[Month])
VAR __table = FILTER('Table',[Year] = __year || ([Year] = __yearPrev && [Month] > __month))
RETURN
SUMMARIZE(__table,[Year],[Month],"My Column",SUM([Value]))

Also, I feel that this link might come in handy for you:


https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



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...

Thanks

 

VAR __month = MAXX(FILTER('Table',[Year]=__year),[Month]) -- This row is not letting meselect Month from the table

Make sure to replace 'Table' with the name of your actual table. Does your table have a Month column? I have this working in a model, you want "Table 1" in the attached file. This builds a table based upon the "Calendar" table.



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...

Thanks, I missed typed your MAXX with MAX,

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.