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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Peter_Yaacoub
Frequent Visitor

Formula to substitute monthly values

Hellooo PBI experts!

 

I have done the ETL process on a Balance Sheet for a group companies where the current month is compared to December of last year (i.e. Jan 2022 vs Dec 2021; Feb 2022 vs Dec 2021; etc.).

I need help with a function so that when February comes and the query is refreshed,  December 2021 values from January table are removed and replaced with December 2021 values from February table.

 

Your help is much appreciated.

1 REPLY 1
amitchandak
Super User
Super User

@Peter_Yaacoub , The flag you wanted is not clear.

 

You can get last year last month for selected value

last year last month = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1*month(Today()),MONTH)))

 

 

Last year last month based on today =
var _max= eomonth(today(),-1*month(Today()))
var Min= eomonth(_max,-1)+1 
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Table'),'Table'[Date] >= _min && 'Table'[Date] <=_max ) )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.