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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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)

 

View solution in original post

4 REPLIES 4
v-yuaj-msft
Community Support
Community Support

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.

 

@v-yuaj-msft 

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...

 

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)

 

@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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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