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
DagdasAlbag
Helper I
Helper I

YTD

Hello,
which dax function do I have to use to get my table to show me the values in YTD. 

I have always added it manually for each year.

values to be displayed in YTD for the last three years

2020 = CALCULATE('Qry_001a: Angelegte Schäden n Schadenart, Schadenmelder 2019-2020'[Angelegte Schäden 2020],FILTER('Qry_001a: Angelegte Schäden n Schadenart, Schadenmelder 2019-2020','Qry_001a: Angelegte Schäden n Schadenart, Schadenmelder 2019-2020'[Schadenanlage].[Date]< DATE(2020,11,20)))

2020-11-25 13_14_54-000_Schadenanlage_Tagesebene_ProGS_20201118 - Power BI Desktop.png

4 REPLIES 4
amitchandak
Super User
Super User

@DagdasAlbag ,

Plot with year and month from date table you will get YTD for all year

If you want to remove December every year

 

YTD Corrected =
var _max = format(today(),"YYYYMM")
return
calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),format('Date'[Date],"YYYYMM")<=_max)

or
YTD Corrected =
var _max = format(today(),"YYYYMM")
return
if(format(max('Date'[Date]),"YYYYMM")<=_max, calculate(Sum('order'[Qty]),DATESYTD('Date'[Date])),blank())

DagdasAlbag
Helper I
Helper I

Can anyone else help me?

amitchandak
Super User
Super User

@DagdasAlbag , is datesytd not working for you

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

or like

YTD QTY forced=
var _max = today()
return
calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),'Date'[Date]<=_max)

 

 

with date table, Take year and month also from date table

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

Hello,
unfortunately it still does not work as it should.

if I use the following formula, I only get the year 2020. But I would like to get every three years after YTD

CALCULATE('Qry_001a: Angelegte Schäden n Schadenart, Schadenmelder 2019-2020'[Angelegte Schäden],
DATESYTD('Qry_001a: Angelegte Schäden n Schadenart, Schadenmelder 2019-2020'[Schadenanlage].[Date],"12/31"))

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