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
Bobbys
Helper III
Helper III

YTD-1

Hello.

I'm having difficulties visualising my YTD for this year and YTD for last year measures.

Bobbys_0-1633677412445.png

As you can see from the chart, the YTD-1 goes on until dec 31st, however, I want it to end at the same time as the YTD line. The YTD line stops at the last date with sales numbers. 
The DAX I've used for YTD is :

YTD = var _lastActualValue = MAX(Sheet1[Date])
RETURN
IF(SELECTEDVALUE(Dates[Date])<=_lastActualValue,
CALCULATE(SUM(Sheet1[Verdi]),DATESYTD(Dates[Date]))
)

And for YTD -1 I've used: 
YTD -1 = CALCULATE([YTD],SAMEPERIODLASTYEAR(Dates[Date]))
 
In a table, the output looks like this:
Bobbys_1-1633677577502.png 
Please, any assistance is well appreciated!

 

3 REPLIES 3
VahidDM
Super User
Super User

Hi @Bobbys 

 

Try this:

 

YTD -1 = CALCULATE([YTD],SAMEPERIODLASTYEAR(Dates[Date]),Dates[Date]<=MAX(Sheet1[Date]))
 
Output=
VahidDM_0-1633856220231.png

 

 

My data:

VahidDM_1-1633856262769.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!


Hello @VahidDM. Thanks for the tip, however, I'm still unable to make it work.

Here's how it looks: 

Bobbys_0-1633860168732.png


I have no idea where it's going wrong and it's really frustrating. 

 

Hi @Bobbys 

 

Is there any relation between your Date and Value tables? Can you share a sample of your data or share your PBIX file? [after removing sensetive data]

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!



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.

Top Solution Authors