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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
honeybee84
Frequent Visitor

Need help with measure MTD and YTD based on data that has 2 date columns

Hi all power bi gurus, 

 

I have a data set that contains actual and forecast (simplified sample below). It has 2 date columns being 'Reporting Period' and 'Month' (2nd date column is to show the monthly phasing). 

In PBI desktop, I have set up a date table and linked it to 1st date column ('Reporting Period'). 

 

Raw data

ProjectReporting PeriodCost VersionCost TypeMonthAmount
AMar-25ActualSalaryJul-24 1,000.00
AMar-25ActualSalaryAug-24    500.00
AMar-25ActualSalarySep-24    800.00
AMar-25ActualSalaryOct-24 1,200.00
AMar-25ActualSalaryNov-24 1,100.00
AMar-25ActualSalaryDec-24    900.00
AMar-25ActualSalaryJan-25    750.00
AMar-25ActualSalaryFeb-25 1,800.00
AMar-25ActualSalaryMar-25    900.00
AMar-25ActualSalaryApr-25 
AMar-25ActualSalaryMay-25 
AMar-25ActualSalaryJun-25 
AMar-25ForecastSalaryJul-24 1,100.00
AMar-25ForecastSalaryAug-24    600.00
AMar-25ForecastSalarySep-24    700.00
AMar-25ForecastSalaryOct-24 1,200.00
AMar-25ForecastSalaryNov-24 1,000.00
AMar-25ForecastSalaryDec-24 1,000.00
AMar-25ForecastSalaryJan-25    800.00
AMar-25ForecastSalaryFeb-25 1,500.00
AMar-25ForecastSalaryMar-25 1,200.00
AMar-25ForecastSalaryApr-25 1,000.00
AMar-25ForecastSalaryMay-25    850.00
AMar-25ForecastSalaryJun-25 1,300.00
AApr-25ActualSalaryJul-24 1,000.00
AApr-25ActualSalaryAug-24    500.00
AApr-25ActualSalarySep-24    800.00
AApr-25ActualSalaryOct-24 1,200.00
AApr-25ActualSalaryNov-24 1,100.00
AApr-25ActualSalaryDec-24    900.00
AApr-25ActualSalaryJan-25    750.00
AApr-25ActualSalaryFeb-25 1,800.00
AApr-25ActualSalaryMar-25    900.00
AApr-25ActualSalaryApr-25    950.00
AApr-25ActualSalaryMay-25 
AApr-25ActualSalaryJun-25 
AApr-25ForecastSalaryJul-24 1,100.00
AApr-25ForecastSalaryAug-24    600.00
AApr-25ForecastSalarySep-24    700.00
AApr-25ForecastSalaryOct-24 1,200.00
AApr-25ForecastSalaryNov-24 1,000.00
AApr-25ForecastSalaryDec-24 1,000.00
AApr-25ForecastSalaryJan-25    800.00
AApr-25ForecastSalaryFeb-25 1,500.00
AApr-25ForecastSalaryMar-25 1,200.00
AApr-25ForecastSalaryApr-25 1,000.00
AApr-25ForecastSalaryMay-25 1,000.00
AApr-25ForecastSalaryJun-25 1,500.00

 

What I'm trying to achieve is actual MTD based on date filter (from date table, linked to 'Reporting Period' column) but the actual MTD should also filter on the 2nd date column ('Month'). 

 

Intended result

 

Date Slicer Apr-25Mar-25
   
   
Actual MTD       950.00       900.00
Actual YTD    9,900.00    8,950.00
   
Forecast MTD    1,000.00    1,200.00
Forecast YTD  10,100.00    9,100.00
   
   
Actual Last Month MTD       900.00 
Actual Last Month YTD    8,950.00 
   
Forecast Last Month MTD    1,200.00 
Forecast Last Month YTD    9,100.00 

 

How to create measures for the above (actual MTD, YTD, actual last month MTD, YTD etc) in power BI?

 

Any help is greatly appreciated.

 

Thank you.  

1 ACCEPTED SOLUTION

Hi @honeybee84,
Thank you for reaching out to the Microsoft fabric community forum.

Based on your requirement, please try the following measures:

Forecast Last Month MTD =

VAR SelectedDate = SELECTEDVALUE(Data[Reporting Period])

VAR FutureMonthDate = FORMAT(DATE(YEAR(SelectedDate), MONTH(SelectedDate + 40), 1), "DD-MM-YYYY")

RETURN

CALCULATE(

    SUM(Data[Amount]),

    Data[Cost Version] = "Forecast",

    Data[Reporting Period] = SelectedDate,

    Data[Month] = Data[Reporting Period] + 30

)

 

Forecast Last Month YTD =

VAR SelectedDate = SELECTEDVALUE(Data[Reporting Period])

VAR FutureMonthDate = DATE(YEAR(SelectedDate), MONTH(SelectedDate) + 1, 1)

RETURN

CALCULATE(

    SUM(Data[Amount]),

    Data[Cost Version] = "Forecast",

    Data[Reporting Period] = SelectedDate,

    Data[Month] <= FutureMonthDate

)

These measures align with your requirement to calculate the forecast values based on the previous month's reporting period logic.


If this information is helpful, please “Accept as solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.

View solution in original post

8 REPLIES 8
v-ssriganesh
Community Support
Community Support

Hi @honeybee84,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you.

 

v-ssriganesh
Community Support
Community Support

Hi @honeybee84,

May I ask if you have resolved this issue? If so, please mark it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

honeybee84
Frequent Visitor

Hi, sample data amended to show period beyond current fiscal year 

ProjectReporting PeriodCost VersionCost TypeMonthAmount
AMar-25ActualSalaryMar-24    500.00
AMar-25ActualSalaryApr-24    700.00
AMar-25ActualSalaryMay-24    800.00
AMar-25ActualSalaryJun-24 1,500.00
AMar-25ActualSalaryJul-24 1,000.00
AMar-25ActualSalaryAug-24    500.00
AMar-25ActualSalarySep-24    800.00
AMar-25ActualSalaryOct-24 1,200.00
AMar-25ActualSalaryNov-24 1,100.00
AMar-25ActualSalaryDec-24    900.00
AMar-25ActualSalaryJan-25    750.00
AMar-25ActualSalaryFeb-25 1,800.00
AMar-25ActualSalaryMar-25    900.00
AMar-25ActualSalaryApr-25 
AMar-25ActualSalaryMay-25 
AMar-25ActualSalaryJun-25 
AMar-25ForecastSalaryMar-24    500.00
AMar-25ForecastSalaryApr-24    700.00
AMar-25ForecastSalaryMay-24    800.00
AMar-25ForecastSalaryJun-24 1,500.00
AMar-25ForecastSalaryJul-24 1,000.00
AMar-25ForecastSalaryAug-24    500.00
AMar-25ForecastSalarySep-24    800.00
AMar-25ForecastSalaryOct-24 1,200.00
AMar-25ForecastSalaryNov-24 1,100.00
AMar-25ForecastSalaryDec-24    900.00
AMar-25ForecastSalaryJan-25    750.00
AMar-25ForecastSalaryFeb-25 1,800.00
AMar-25ForecastSalaryMar-25    900.00
AMar-25ForecastSalaryApr-25 1,000.00
AMar-25ForecastSalaryMay-25    850.00
AMar-25ForecastSalaryJun-25 1,300.00
AApr-25ActualSalaryMar-24    500.00
AApr-25ActualSalaryApr-24    700.00
AApr-25ActualSalaryMay-24    800.00
AApr-25ActualSalaryJun-24 1,500.00
AApr-25ActualSalaryJul-24 1,000.00
AApr-25ActualSalaryAug-24    500.00
AApr-25ActualSalarySep-24    800.00
AApr-25ActualSalaryOct-24 1,200.00
AApr-25ActualSalaryNov-24 1,100.00
AApr-25ActualSalaryDec-24    900.00
AApr-25ActualSalaryJan-25    750.00
AApr-25ActualSalaryFeb-25 1,800.00
AApr-25ActualSalaryMar-25    900.00
AApr-25ActualSalaryApr-25    950.00
AApr-25ActualSalaryMay-25 
AApr-25ActualSalaryJun-25 
AApr-25ForecastSalaryMar-24    500.00
AApr-25ForecastSalaryApr-24    700.00
AApr-25ForecastSalaryMay-24    800.00
AApr-25ForecastSalaryJun-24 1,500.00
AApr-25ForecastSalaryJul-24 1,000.00
AApr-25ForecastSalaryAug-24    500.00
AApr-25ForecastSalarySep-24    800.00
AApr-25ForecastSalaryOct-24 1,200.00
AApr-25ForecastSalaryNov-24 1,100.00
AApr-25ForecastSalaryDec-24    900.00
AApr-25ForecastSalaryJan-25    750.00
AApr-25ForecastSalaryFeb-25 1,800.00
AApr-25ForecastSalaryMar-25    900.00
AApr-25ForecastSalaryApr-25    950.00
AApr-25ForecastSalaryMay-25 1,000.00
AApr-25ForecastSalaryJun-25 1,500.00

 

intended outcome

 

Date Slicer Apr-25Mar-25
   
   
Actual MTD       950.00       900.00
Actual YTD    9,900.00    8,950.00
Actual Life to Date (LTD)  13,400.00  12,450.00
   
   
   
   
Forecast Last Month MTD    1,000.00<--Apr-25 month forecast based on reporting period Mar-25 (which is M-1 from date slicer)
Forecast Last Month YTD    9,950.00<--Apr-25 YTD forecast based on reporting period Mar-25 (which is M-1 from date slicer)

Hi @honeybee84,
Thank you for reaching out to the Microsoft fabric community forum.

Based on your requirement, please try the following measures:

Forecast Last Month MTD =

VAR SelectedDate = SELECTEDVALUE(Data[Reporting Period])

VAR FutureMonthDate = FORMAT(DATE(YEAR(SelectedDate), MONTH(SelectedDate + 40), 1), "DD-MM-YYYY")

RETURN

CALCULATE(

    SUM(Data[Amount]),

    Data[Cost Version] = "Forecast",

    Data[Reporting Period] = SelectedDate,

    Data[Month] = Data[Reporting Period] + 30

)

 

Forecast Last Month YTD =

VAR SelectedDate = SELECTEDVALUE(Data[Reporting Period])

VAR FutureMonthDate = DATE(YEAR(SelectedDate), MONTH(SelectedDate) + 1, 1)

RETURN

CALCULATE(

    SUM(Data[Amount]),

    Data[Cost Version] = "Forecast",

    Data[Reporting Period] = SelectedDate,

    Data[Month] <= FutureMonthDate

)

These measures align with your requirement to calculate the forecast values based on the previous month's reporting period logic.


If this information is helpful, please “Accept as solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.

Hi @honeybee84,
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please accept it as a solution and give it a 'Kudos' so other community members with similar problems can find a solution faster.
Thank you.

ullassl1991
Helper I
Helper I

Hi @honeybee84 if you create a relationship with date from calender table and Reporting period from fact table, the MTD calculated wont give you the value that is mentioned above since we have multiple entry in the data the sum for month Apr-25 and Mar-25 will high than the given value.MTD for Apr-25 = 9900 and March-25=8950

danextian
Super User
Super User

Hi @honeybee84 

 

It is easier to do time intelligence calculations whether with time intelligence functions or not if your're using actual dates instead of texts.  Please see the attached sample pbix.

danextian_0-1747291441845.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

thank you very much Dane, your solution is correct for the earlier sample, but I just found out my data is beyond 1 fiscal year so need further tweak to the measures. I've amended the sample data in the above. Thanks so much, any guidance is very appreciated. 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.