Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

YTD to current date

Good Morning

 

I have the following measure for year to date, my year needs to end on the 31st October.

When i add the measure to a line graph it shows up to the end of 31st October 23, i only want to see up to today.

 

YTD =
TOTALYTD(
    [TotalOrders],
'Date'[created_date_time].[Date],
"10/31"
)
 
I also need to be able to do this for last year to date. I am currently using the same measure and using filters on the chart to do this.
 
Thank you for your help
 

1 Reply

  • Anonymous , First of all use date table , date of your table should join with date table

     

    YTD =
    calculate(
    [TotalOrders],
    datesytd( 'Date'[Date],
    "10/31"
    ), 'Date'[Date] <= today())

     

    or

     

    YTD =
    var _omax = format(if(isfiltered('Date'),MAXX( allselected( 'Date') , 'Date'[Date]) , today()), "MMDD")
    var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
    var _min = if(month(_max) <10, Date(year(_max)-1,10,1) ,Date(year(_max),10,1) )
    return
    CALCULATE(calculate([net], filter('Date'), format('Date'[Date], "MMDDD") <=_omax) ,DATESBETWEEN('Date'[Date],_min,_max))