cancel
Showing results for
Did you mean:
Highlighted
Helper III

## Previous Fiscal YTD DAX Not working

I need to calculate Previous Fiscal Year to date vs Current Fiscal Year to date.

Right now I have Fiscal YTD by:

Fiscal YTD Net Sales = totalytd(sum(VDC_EDW[Net_Sales_Amount]),'Calendar Table'[Date],"3/31")
^ This calculation works correctly

Then I try to get Previous Fiscal Yead to Date with the following:
Fiscal PYTD Net Sales = calculate([Fiscal YTD Net Sales],DATEADD('Calendar Table'[Date],-1,YEAR))
^ This Calculation does not work

Given that today is 1/19/2020.
I am seeing 4/1/2019-1/19/2020 for current Fiscal YTD.(Which is what I need)
I would expect to see 4/1/2018-1/19/2019 for previous fiscal year to date but I am not getting that result.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User I

## Re: Previous Fiscal YTD DAX Not working

Fiscal YTD Net Sales = CALCULATE(sum(VDC_EDW[Net_Sales_Amount]),DATESYTD('Calendar Table'[Date],"3/31"))

Then to get Previous Fiscal Yead to Date with the following:
Fiscal PYTD Net Sales = calculate([Fiscal YTD Net Sales],SAMEPERIODLASTYEAR('Calendar Table'[Date]))

If this helps, mark it as a solution.
Kudos are nice too
11 REPLIES 11
Highlighted
Super User I

## Re: Previous Fiscal YTD DAX Not working

Create a variable and use it for previous year.

Var a = PARALLELPERIOD('Calendar Table'[Date],-1,YEAR)

Fiscal PYTD Net Sales = totalytd(sum(VDC_EDW[Net_Sales_Amount]),a,"3/31")

or

totalytd(sum(VDC_EDW[Net_Sales_Amount]),PARALLELPERIOD('Calendar Table'[Date],-1,YEAR),"3/31")

If this helps, mark it as a solution.

kudos are nice too.

Highlighted
Helper III

## Re: Previous Fiscal YTD DAX Not working

Hi @VasTg ,

Thanks for the quick response.

I'm not quite sure how to use the first one as I am not well versed in variables.

I tried the second one:

Fiscal PYTD Net Sales = totalytd(sum(VDC_EDW[Net_Sales_Amount]),PARALLELPERIOD('Calendar Table'[Date],-1,YEAR),"3/31")

The results were the same numbers as Current Fiscal Year to Date up to December 31 and did not include up to the current day. (see below)

Highlighted
Helper III

## Re: Previous Fiscal YTD DAX Not working

Sorry the image didnt post the first time

Highlighted
Super User I

## Re: Previous Fiscal YTD DAX Not working

Fiscal YTD Net Sales = CALCULATE(sum(VDC_EDW[Net_Sales_Amount]),DATESYTD('Calendar Table'[Date],"3/31"))

Then to get Previous Fiscal Yead to Date with the following:
Fiscal PYTD Net Sales = calculate([Fiscal YTD Net Sales],SAMEPERIODLASTYEAR('Calendar Table'[Date]))

If this helps, mark it as a solution.
Kudos are nice too
Highlighted
Super User IV

## Re: Previous Fiscal YTD DAX Not working

Any reason for not having period end date for last year.

These should work. Also make sure Date table is marked as Date in Data view

``````YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(('Date'[Date]),"3/31"))

Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"3/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"3/31"))``````

My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Community Support

## Re: Previous Fiscal YTD DAX Not working

Hi @tstackhouse ,

``````Measure 2 =
CALCULATE(
SUM(Sales[Sales]),
DATESYTD(SAMEPERIODLASTYEAR(Date[Date]), "3/31")
)``````

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Resolver I

## Re: Previous Fiscal YTD DAX Not working

Hi All,

I have tried all the possible solution mentioned in this Post , to get the YTD for previous year. It is not working for me.

It seems Date Table is not able to filter the Sales Date. I have used [Date] from Date Table in DAX Query.

Also, Date Table is marked as Date Table.  There is a 1 to Many relationship between Date Table and Sales Table

Here is how I created Date table

Date =
VAR MinYear = YEAR ( MIN ( Sales_Invoice_Header[Posting Date] ) )
VAR MaxYear = YEAR ( MAX ( Sales_Invoice_Header[Posting Date] ) )
RETURN
FILTER (
CALENDARAUTO( ),
AND ( YEAR ( [Date] ) >= MinYear, YEAR ( [Date] ) <= MaxYear )
),
"FY YEAR", IF(MONTH([Date]) >=9 , (YEAR([Date]) + 1), YEAR([Date])),
"Calendar Year", "CY " & YEAR ( [Date] ),
"Month Name", FORMAT ( [Date], "mmmm" ),
"Month Number", MONTH ( [Date] ),
"Weekday", FORMAT ( [Date], "dddd" ),
"Weekday number", WEEKDAY( [Date] ),
"Quarter", "Q" & TRUNC ( ( MONTH ( [Date] ) - 1 ) / 3 ) + 1
)

Highlighted
Super User IV

## Re: Previous Fiscal YTD DAX Not working

Does your sales date is having timestamp. If so then date join might noe working properly.

Create date column

Sales Dt =[Sales Date].date

Can you share sample data and sample output.

My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Resolver I

## Re: Previous Fiscal YTD DAX Not working

@amitchandak Yes, you pointed out right. All my dates in fact tables are with timestamp.

But, I already converted the date format to mm/dd/yyyy, in power view but not in power query

Also, the language setting for my PowerBI and my laptop is english (US), so to avoid date confusion.

But, Let me try with your suggestion . Thanks Amit

Announcements

#### August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

#### July 2020 Community Highlights

Learn about the exciting things that happened in July.

#### Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

#### Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors