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
admin_xlsior
Post Prodigy
Post Prodigy

Ytd up to this month

Hi,

 

How to have YTD up to this month, as well as YTD last year ?

My measure now is like this :

Purchase amount YTD CY = CALCULATE(
                                [Purchase amount],
                                DATESYTD('Purchase order dates'[Date])
                                )

 

Purchase amount YTD PY = CALCULATE(
                                [Purchase amount YTD CY],
                                SAMEPERIODLASTYEAR('Purchase order dates'[Date])
)

 

At this moment, my report is like this :

admin_xlsior_0-1617949323144.png

Thanks

 

1 ACCEPTED SOLUTION
v-yuaj-msft
Community Support
Community Support

Hi @admin_xlsior ,

 

Based on your description, you can create two measures as follows.

Here is my test table.

v-yuaj-msft_0-1618395479404.png

Purchase amount = SUM('Table'[Value])
Purchase amount YTD CY =
IF (
MAX ( 'Table'[Date].[MonthNo] ) > MONTH ( TODAY () ),
BLANK (),
SUMX (
FILTER (
ALL ( 'Table' ),
'Table'[Date] <= MAX ( 'Table'[Date] )
&& YEAR ( TODAY () ) = YEAR ( 'Table'[Date] )
),
[Purchase amount]
)
)
Purchase amount YTD PY =
IF (
MAX ( 'Table'[Date].[MonthNo] ) > MONTH ( TODAY () ),
BLANK (),
SUMX (
FILTER (
ALL ( 'Table' ),
YEAR ( 'Table'[Date] )
= YEAR ( MAX ( 'Table'[Date] ) ) - 1
&& MONTH ( 'Table'[Date] ) <= MONTH ( MAX ( 'Table'[Date] ) )
),
[Purchase amount]
)
)

Result:

v-yuaj-msft_1-1618395627114.png

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.

 

View solution in original post

2 REPLIES 2
v-yuaj-msft
Community Support
Community Support

Hi @admin_xlsior ,

 

Based on your description, you can create two measures as follows.

Here is my test table.

v-yuaj-msft_0-1618395479404.png

Purchase amount = SUM('Table'[Value])
Purchase amount YTD CY =
IF (
MAX ( 'Table'[Date].[MonthNo] ) > MONTH ( TODAY () ),
BLANK (),
SUMX (
FILTER (
ALL ( 'Table' ),
'Table'[Date] <= MAX ( 'Table'[Date] )
&& YEAR ( TODAY () ) = YEAR ( 'Table'[Date] )
),
[Purchase amount]
)
)
Purchase amount YTD PY =
IF (
MAX ( 'Table'[Date].[MonthNo] ) > MONTH ( TODAY () ),
BLANK (),
SUMX (
FILTER (
ALL ( 'Table' ),
YEAR ( 'Table'[Date] )
= YEAR ( MAX ( 'Table'[Date] ) ) - 1
&& MONTH ( 'Table'[Date] ) <= MONTH ( MAX ( 'Table'[Date] ) )
),
[Purchase amount]
)
)

Result:

v-yuaj-msft_1-1618395627114.png

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.

 

amitchandak
Super User
Super User

@admin_xlsior , Try like these examples with date tbale

 

Last YTD = CALCULATE([Purchase amount],DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

YTD forced=
var _max = maxx('order',[Order date])
return
if(max('Date'[Date])<=_max, calculate([Purchase amount],DATESYTD('Date'[Date])), blank())
//calculate([Purchase amount],DATESYTD('Date'[Date]),filter('Date','Date'[Date]<=_max))
//calculate(TOTALYTD([Purchase amount],'Date'[Date]),filter('Date','Date'[Date]<=_max))

 

 

LYTD forced=
var _max1 =maxx('order',[Order date])
var _max = date(year(_max1)-1,month(_max1),day(_max1))
return
CALCULATE([Purchase amount],DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)

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.