Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

YTD Average Calculation

Can anyone help me with the YTD Average calculation?

 

I have a table visual as shown below. "A" and "B" are DAX calculations which are giving me % calculations by each month.

 

Now, I need to create YTD A and YTD B calculations using DAX

 

RegionDatesABYTD AYTD B
ABC1/1/201982%40%  
ABC2/1/201988%12%  
ABC3/1/2019119%22%  
ABC4/1/201967%35%  
ABC5/1/201946%45%  
ABC6/1/201955%55%  
ABC7/1/201929%65%  
ABC8/1/201934%90%  
ABC9/1/201926%45%  

 

 

Now If I filter on Date to select 8/1/2019 then I would expect something like this

 

I did this in excel

YTD A  =AVERAGE(C2:C9)

YTD B =AVERAGE(D2:D9)

 

RegionDatesABYTD AYTD B
ABC8/1/201934%90%65%46%

 

Any help would be really appreciated.

 

Thanks,

Fareed.,

1 Reply

  • Try Datesytd or totalytd

     

    Year  = CALCULATE(SUM(table[column]),DATESYTD('Date'[Date Filer]))
    Last Year  = CALCULATE(SUM(table[column]),DATESYTD(dateadd('Date'[Date Filer],-12,MONTH)))
    
    
    Year Sales = CALCULATE(TOTALYTD(sum(Sales[Sales Amount]),('Date'[Date Filer])))
    Year Sales = CALCULATE(TOTALYTD(sum(Sales[Sales Amount]),dateadd('Date'[Date Filer].-12,month)))

     

    Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
    Thanks.

    My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601