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
dfox09
Helper III
Helper III

combine SAMEPERIODLASTYEAR with DATEADD

Is it possible to combine SAMEPERIODLASTYEAR with DATEADD? Our Fiscal Year starts in May and ends in April therefor I can't use the normal forecasting methods as those companies with a normal calendar year as their Fiscal year. Is it possible to set up a formula in DAX that would look at the current month and calculate the average revenue between the proceeding month in a prior Fiscal Year and the last month of the prior Fiscal Year? For example, if I am going to forecast July (2020) revenue, I would take the average of each monthly revenue from August, 2019 (the proceeding month of the prior Fiscal year) through April, 2020 (the last Fiscal month of the prior Fiscal Year. 

I can do this in Excel but haven't figured out how to write something like this in DAX.

Here is the DAX formula that I came up with but it doesn't work.

Production Forecast =
VAR _Start_date = SAMEPERIODLASTYEAR(DATEADD(DimAccountingPeriod[BeginDate].[Month],1 ,MONTH))
VAR Cur_prod = 'Measures Table'[Production] - not able to use in formula below.
VAR _End_date = DATE(2020, 04,30)

RETURN
            CALCULATE(
AVERAGEX('TBL_Actuals',TBL_Actuals[Producer Revenue]),
DATESBETWEEN(DimAccountingPeriod[BeginDate], _Start_date , _End_date)
)

Any help would be appreciated!

Don

2 REPLIES 2
Greg_Deckler
Super User
Super User

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


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

Thank you for replying. As a newbie, I got stuck when attempting to apply your solution to my issue. A couple of questions;

Within the first measure, Is T'heHardWay' created on the fly? DAX couldn't find the table (of course, since it didn't previously exist).

I created my own date but still don't know how to write the DAX formula to calculate a forecast given the constraints of our Fiscal Year.

Don

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.

Top Solution Authors