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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
admin11
Memorable Member
Memorable Member

How to add one more condition to my YTD expression

Hi All

 

Sales YTD =
 
Below expression working fine :-

var _max = date(year(today())-0,month(today()),day(today()))
return
TOTALYTD(('SALES'[SALES_]),dateadd('Date'[Date],-0,year),'Date'[Date]<=_max)

May i know how to add below condition to above expression :-
 
filter(SALES,[SOURCE] = "TS")
 
admin11_0-1616307597564.png

I get above error msg when i try :-

Sales YTD TDS =
var _max = date(year(today())-0,month(today()),day(today()))
return
TOTALYTD((filter(SALES,[SOURCE] = "TS"),'SALES'[SALES_]),dateadd('Date'[Date],-0,year),'Date'[Date]<=_max)
 
Below is my PBI file :-
 
2 ACCEPTED SOLUTIONS
themistoklis
Community Champion
Community Champion

Hello @admin11 ,

 

Please try the following formula:

 

Sales YTD TDS = 
var _max = date(year(today())-0,month(today()),day(today()))
return
Calculate(TOTALYTD(('SALES'[SALES_]),dateadd('Date'[Date],-0,year),'Date'[Date]<=_max),filter(SALES,[SOURCE] = "TS"))

View solution in original post

PhilipTreacy
Super User
Super User

@admin11 

Hi Paul,

Your measures can be simplified, e.g. for Sales YTD

Sales YTD = TOTALYTD(('SALES'[SALES_]),'Date'[Date],'Date'[Date]<=TODAY())

 

and for this particular question, Sales YTD TS

Sales YTD TS = CALCULATE(TOTALYTD(('SALES'[SALES_]),'Date'[Date],'Date'[Date]<=TODAY()), FILTER('SALES', 'SALES'[SOURCE] = "TS"))

 

Download your PBIX

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

3 REPLIES 3
PhilipTreacy
Super User
Super User

@admin11 

Hi Paul,

Your measures can be simplified, e.g. for Sales YTD

Sales YTD = TOTALYTD(('SALES'[SALES_]),'Date'[Date],'Date'[Date]<=TODAY())

 

and for this particular question, Sales YTD TS

Sales YTD TS = CALCULATE(TOTALYTD(('SALES'[SALES_]),'Date'[Date],'Date'[Date]<=TODAY()), FILTER('SALES', 'SALES'[SOURCE] = "TS"))

 

Download your PBIX

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


@PhilipTreacy 

Thank you for sharing the shorter expression.

For me since i no good in writng script , so i prefer YTD & LYTD as below :-

 
Sales YTD =
var _max = date(year(today())-0,month(today()),day(today()))
return
TOTALYTD(('SALES'[SALES_]),dateadd('Date'[Date],-0,year),'Date'[Date]<=_max)
Sales LYTD =
var _max = date(year(today())-1,month(today()),day(today()))
return
TOTALYTD(('SALES'[SALES_]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)
 
Which more easy for me to manage.
 
Paul
themistoklis
Community Champion
Community Champion

Hello @admin11 ,

 

Please try the following formula:

 

Sales YTD TDS = 
var _max = date(year(today())-0,month(today()),day(today()))
return
Calculate(TOTALYTD(('SALES'[SALES_]),dateadd('Date'[Date],-0,year),'Date'[Date]<=_max),filter(SALES,[SOURCE] = "TS"))

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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