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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
admin11
Memorable Member
Memorable Member

How to modify my exiting LYTD expression to get 2021 jan till mar amount ?

Hi All

Below expression only give me YTD amount , may i know how to get Jan till Mar 2021 total amount ?
Sales LYTD =
var _max = date(year(today())-1,month(today()),day(today()))
return
TOTALYTD(('SALES'[SALES_]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)

admin11_0-1616132624839.png

 

Paul

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@admin11 , This formula seems correct. It should give Jan to march

 

Try one three versions . Two in comments //

LYTD QTY forced=
var _max = date(year(today())-1,month(today()),day(today()))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
//OR
//CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)

//or
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @admin11 ,

 

Your sample .pbix file is deleted. Please re-upload it. Please correct me if my understanding is wrong.

If you just want to sum the sales of which dates are from Jan 2021 to March 2021, you could use the "TOTALYTD()" function directly.

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

 

@Anonymous 

Apprecaite very much for want to help me solve my issue , By the way i need your help to solve the below post , as this is more critial , Hope that you can take a look :-

https://community.powerbi.com/t5/Desktop/How-to-modify-my-LYTD-expression-So-that-i-can-get-Jan-2020/td-p/1733947

 

amitchandak
Super User
Super User

@admin11 , This formula seems correct. It should give Jan to march

 

Try one three versions . Two in comments //

LYTD QTY forced=
var _max = date(year(today())-1,month(today()),day(today()))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
//OR
//CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)

//or
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 

 

I have try your expression :-

LYTD SALES AMIT =
var _max = date(year(today())-1,month(today()),day(today()))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('SALES'[sales]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
 
Not error but it display null
 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors