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
cristianml
Post Prodigy
Post Prodigy

undefined

Hi,

 

I Need a DAX Formula to calculate in the same page 3 different measures depending of the period:

MTD: calculate previous month (April 2019)

YTD: Calculate from SEP 2018 to APRIL 2019

FY: Calculate from SEP 2018 to AUGUST 2019  (I already have a table mapping for this but have an issue when I apply a YTD formula from here: https://www.sqlbi.com/blog/marco/2018/05/22/time-intelligence-issues-in-dax-for-fiscal-years-startin...

SUMMARY.png

Thanks and regards.

 

 

 

2 REPLIES 2
v-danhe-msft
Employee
Employee

Hi @cristianml ,

Could you please post some simple sample data and your desired result to have a test if possible? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-danhe-msft ,

 

Basically I have an issue when I use this formula :

 

YTD Actual Cost =
CALCULATE (
[Actual Costs],
VAR FirstFiscalMonth = 9 -- Set the first month of the fiscal year
VAR LastDay =
MAX ( 'List Period'[Date Period] )
VAR LastMonth =
MONTH ( LastDay )
VAR LastYear =
YEAR ( LastDay )
- IF ( LastMonth < FirstFiscalMonth, 1 )
VAR FilterYtd =
DATESBETWEEN (
'List Period'[Date Period],
DATE ( LastYear, FirstFiscalMonth, 1 ),
LastDay
)
RETURN
FilterYtd

 

When I use "Fiscal Year" with Slicer the formula "YTD Actual Cost" shows future values because is considering the complete year (Sep18 to Aug-19) instead of show me until last month that Should go from Sep18 to April-19.

PERIODS.png

What I would need is to modify the "YTD Actual Cost" formula to calculate till last month instead of using any Date period with Slicer.

 

With this I would be able to see two different measures:

1 - (YTD) that goes from Sep18 (VAR FirstFiscalMonth = 9) to last month

2 - (FY) that will show values by selecting "Fiscal Year" in Slicer

For MTD I have this measure that works fine and could be useful as an idea to modify the "YTD Actual Cost" formula:

 

MTD Actual Cost = CALCULATE([Actual Costs], // Sum Amount
DATESBETWEEN('List Period'[Date Period], // Based on Dates Between
Date(YEAR(EDATE(today(),-1)),MONTH(EDATE(today(),-1)),1), // Date having Year = Today -1 Month / Month = today -1 Month, and Day = 1
EOMONTH(today(),-1))) // End Of Month effective today() -1 month

 

Hope I have explained myself better.

 

Thanks and regards

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.