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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
arniet
Frequent Visitor

YTD (this year) vs YTD (last year)

Hello, I need advice on why my YTD (this year) is showing data for 1 Jul 2020 to 2 Jul 2020, while my YTD (last year) is showing data for all of Jul 2019? Shouldn't it be showing data for 1 Jul 2019 to 2 Jul 2020? 

Capture4.PNG

 

kind regards

arnie

 

1 ACCEPTED SOLUTION
arniet
Frequent Visitor

Hi Everyone,

 

I have worked out the DAX that resolves all MTD LY, QTD LY and YTD LY. Added bonus was creating the 4th LY measure that was based just on any actual date of the year. Here goes:

 

MTD (Prev.) Net Sales ($) = CALCULATE(TOTALMTD([Net Sales Exc. Tax],
'Invoice Date Dimension'[Invoice Date]),
FILTER(DATESQTD(SAMEPERIODLASTYEAR('Invoice Date Dimension'[Invoice Date])),
MONTH('Invoice Date Dimension'[Invoice Date])<MONTH(TODAY()) ||
(MONTH('Invoice Date Dimension'[Invoice Date]) = MONTH(TODAY()) &&
DAY('Invoice Date Dimension'[Invoice Date]) <= DAY(TODAY()))))
 
QTD (Prev.) Net Sales ($) = CALCULATE(TOTALQTD([Net Sales Exc. Tax],
'Invoice Date Dimension'[Invoice Date]),
FILTER(DATESQTD(SAMEPERIODLASTYEAR('Invoice Date Dimension'[Invoice Date])),
MONTH('Invoice Date Dimension'[Invoice Date])<MONTH(TODAY()) ||
(MONTH('Invoice Date Dimension'[Invoice Date]) = MONTH(TODAY()) &&
DAY('Invoice Date Dimension'[Invoice Date]) <= DAY(TODAY()))))
 
YTD (Prev.) Net Sales ($) = CALCULATE(TOTALYTD([Net Sales Exc. Tax],
'Invoice Date Dimension'[Invoice Date],"30/6"),
FILTER(DATESYTD(SAMEPERIODLASTYEAR('Invoice Date Dimension'[Invoice Date])),
MONTH('Invoice Date Dimension'[Invoice Date])<MONTH(TODAY()) ||
(MONTH('Invoice Date Dimension'[Invoice Date]) = MONTH(TODAY()) &&
DAY('Invoice Date Dimension'[Invoice Date]) <= DAY(TODAY()))))
 
Net Sales Exc. Tax Same Time Last Year =
CALCULATE(SUM('Current Order Detail Fact'[Net Sales Amount Excl Tax]),
FILTER(SAMEPERIODLASTYEAR('Invoice Date Dimension'[Invoice Date]),
MONTH('Invoice Date Dimension'[Invoice Date])<MONTH(TODAY()) ||
(MONTH('Invoice Date Dimension'[Invoice Date]) = MONTH(TODAY()) &&
DAY('Invoice Date Dimension'[Invoice Date]) <= DAY(TODAY()))))

Capture7.PNG

 

View solution in original post

7 REPLIES 7
arniet
Frequent Visitor

Hi Everyone,

 

I have worked out the DAX that resolves all MTD LY, QTD LY and YTD LY. Added bonus was creating the 4th LY measure that was based just on any actual date of the year. Here goes:

 

MTD (Prev.) Net Sales ($) = CALCULATE(TOTALMTD([Net Sales Exc. Tax],
'Invoice Date Dimension'[Invoice Date]),
FILTER(DATESQTD(SAMEPERIODLASTYEAR('Invoice Date Dimension'[Invoice Date])),
MONTH('Invoice Date Dimension'[Invoice Date])<MONTH(TODAY()) ||
(MONTH('Invoice Date Dimension'[Invoice Date]) = MONTH(TODAY()) &&
DAY('Invoice Date Dimension'[Invoice Date]) <= DAY(TODAY()))))
 
QTD (Prev.) Net Sales ($) = CALCULATE(TOTALQTD([Net Sales Exc. Tax],
'Invoice Date Dimension'[Invoice Date]),
FILTER(DATESQTD(SAMEPERIODLASTYEAR('Invoice Date Dimension'[Invoice Date])),
MONTH('Invoice Date Dimension'[Invoice Date])<MONTH(TODAY()) ||
(MONTH('Invoice Date Dimension'[Invoice Date]) = MONTH(TODAY()) &&
DAY('Invoice Date Dimension'[Invoice Date]) <= DAY(TODAY()))))
 
YTD (Prev.) Net Sales ($) = CALCULATE(TOTALYTD([Net Sales Exc. Tax],
'Invoice Date Dimension'[Invoice Date],"30/6"),
FILTER(DATESYTD(SAMEPERIODLASTYEAR('Invoice Date Dimension'[Invoice Date])),
MONTH('Invoice Date Dimension'[Invoice Date])<MONTH(TODAY()) ||
(MONTH('Invoice Date Dimension'[Invoice Date]) = MONTH(TODAY()) &&
DAY('Invoice Date Dimension'[Invoice Date]) <= DAY(TODAY()))))
 
Net Sales Exc. Tax Same Time Last Year =
CALCULATE(SUM('Current Order Detail Fact'[Net Sales Amount Excl Tax]),
FILTER(SAMEPERIODLASTYEAR('Invoice Date Dimension'[Invoice Date]),
MONTH('Invoice Date Dimension'[Invoice Date])<MONTH(TODAY()) ||
(MONTH('Invoice Date Dimension'[Invoice Date]) = MONTH(TODAY()) &&
DAY('Invoice Date Dimension'[Invoice Date]) <= DAY(TODAY()))))

Capture7.PNG

 

stevedep
Memorable Member
Memorable Member

Hi @stevedep 

 

My apologies for not being clear, my YTD calculations are based on the financial year, starting Jul.

 

kind regards

arnie

Create a date table identifying your fiscal years. Will assist you greatly in the long run. Then you're able to create measures based off of your fiscal qtrs and years opposed to jan-dec. Just a tip.

Hi @AlexAlberga727 , thanks for the advice. Yes, I am currently using a date table that identifies my fiscal years. Still getting stuck with the DAX for some reason.

Capture5.PNGCapture6.PNG

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.