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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
giofranc
New Member

How to get the last Period Month from selected value in drop down list of Current Month

I have a request, my table data set have columns "FiscalMonth" 1,2,...12...

FiscalYear: 15,16,17...20

Amount = Totals (Already Calculated from dB)

So I want to display the current period amount and last period Amount

I was able to accomplish only the current Period using this formula

CurrentPeriod = CALCULATE(SUM(GLTotals[Amount]),FILTER(GLTotals,GLTotals[FiscalPeriod]=SELECTEDVALUE(GLTotals[FiscalPeriod])))
I need some help on how to retrieve LastPeriod on a matrix.
This is the table dataset.BIC.PNG 
E.G If I selected 12 in the drop down, the LastPeriod has to be calculation of FiscalMonth11
LastPeriod ==?
 
Thank you for your help
 
 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

A calculation like this can work. but better you have a date calendar table and then do date calc on calendar table.

 

last Period =
var _period1= maxx(GLTotals,SELECTEDVALUE(GLTotals[FiscalPeriod]))
var _year1= maxx(GLTotals,SELECTEDVALUE(GLTotals[FiscalYear]))
var _period = if(_period1=12, 1, _period1-1)
var _year = if(_period1=12, _year-1, _year)
 

CALCULATE(SUM(GLTotals[Amount]),FILTER(all(GLTotals),GLTotals[FiscalPeriod]=_period1 && GLTotals[FiscalYear] =_year ))

 

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

A calculation like this can work. but better you have a date calendar table and then do date calc on calendar table.

 

last Period =
var _period1= maxx(GLTotals,SELECTEDVALUE(GLTotals[FiscalPeriod]))
var _year1= maxx(GLTotals,SELECTEDVALUE(GLTotals[FiscalYear]))
var _period = if(_period1=12, 1, _period1-1)
var _year = if(_period1=12, _year-1, _year)
 

CALCULATE(SUM(GLTotals[Amount]),FILTER(all(GLTotals),GLTotals[FiscalPeriod]=_period1 && GLTotals[FiscalYear] =_year ))

 

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

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
Greg_Deckler
Community Champion
Community Champion

You would use the time intelligence functions or see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

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

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 Solution Authors
Top Kudoed Authors