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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AshDil
Helper V
Helper V

Want to show Current Year YTD till Previous month

Hi,

 

I have tried to calculate YTD till previous month using following formula,
YTD sales = Calculate(TOTALYTD('TABLE'[SALES],'CALENDAR'[DATE'), FILTER('CALENDAR','CALENDAR'[YEAR] = YEAR(TODAY()) && 'CALENDAR'[MONTH_NO] = MONTH(TODAY())-1))))

 

But I'm not getting correct results.

Please help me to do it.

Thanks,

AshDil.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@AshDil , Try a measure like

 

YTD Today till last month =
var _min = Date(year(Today()),1,1)
var _day = eomonth(today(),-1)
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date] >=_min && 'Date'[Date] <= _day) )

 

Remove all date date it date is not selected

 

YTD Today till last month =
var _min = Date(year(Today()),1,1)
var _day = eomonth(today(),-1)
return
CALCULATE(sum('Table'[Qty]), FILTER(('Date'),'Date'[Date] >=_min && 'Date'[Date] <= _day) )

View solution in original post

Jihwan_Kim
Super User
Super User

Hi, 

Please check the below picture and the attached pbix file.

All measures are in the attached pbix file.

 

Picture3.png

 

Sales total: =
SUM( Data[Sales] )
 
Sales YTD: =
CALCULATE( [Sales total:], DATESYTD('Calendar'[Date] ))
 
Sales YTD until previous month: =
IF ( HASONEVALUE ( 'Calendar'[Month & Year] ), [Sales YTD:] - [Sales total:] )
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, 

Please check the below picture and the attached pbix file.

All measures are in the attached pbix file.

 

Picture3.png

 

Sales total: =
SUM( Data[Sales] )
 
Sales YTD: =
CALCULATE( [Sales total:], DATESYTD('Calendar'[Date] ))
 
Sales YTD until previous month: =
IF ( HASONEVALUE ( 'Calendar'[Month & Year] ), [Sales YTD:] - [Sales total:] )
 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


amitchandak
Super User
Super User

@AshDil , Try a measure like

 

YTD Today till last month =
var _min = Date(year(Today()),1,1)
var _day = eomonth(today(),-1)
return
CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date] >=_min && 'Date'[Date] <= _day) )

 

Remove all date date it date is not selected

 

YTD Today till last month =
var _min = Date(year(Today()),1,1)
var _day = eomonth(today(),-1)
return
CALCULATE(sum('Table'[Qty]), FILTER(('Date'),'Date'[Date] >=_min && 'Date'[Date] <= _day) )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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