Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX YTD problem

Hello guys! I am new to Power BI and I need some help. YTD calculation stops working correctly when I add  Date column not from the Date Hierarchy. This is my DAX formula: Actual YTD 2 = CALCULA...
  • amitchandak's avatar
    4 years ago

    Anonymous , try like the example. The two comments at end are alternate

     

    YTD QTY forced= 
    var _max = //or maxx(allselected('Order'),'order'[Date]) //max date in table
    return
    if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESYTD('Date'[Date])), blank())
    //or
    //calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),filter('Date','Date'[Date]<=_max))
    //calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]<=_max))