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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors