ssas - DAX. Previous year Amount -


i have single table in powerpivot.

my columns account, amount , date. want calculate prevyearamount, can't fin correct formula.

sample data:

account      amount     date            prevyearamount  1              100      01/01/2016      90  1              120      02/01/2016      200  2              130      01/01/2016      108  2              103      01/01/2015   2              105      01/01/2015   1              90       01/01/2015   1              200      02/01/2015  

tried

=calculate(sum(hoja1[amount]);filter(hoja1;dateadd(hoja1[date];-1;year));filter(hoja1;hoja1[account])) 

but returns 350 rows.

also tried:

=calculate(sum(hoja1[importe]);datesytd(sameperiodlastyear(hoja1[fecha]))) 

but returns blank

this should trick:

calculate(sum('table1'[amount]);sameperiodlastyear('table1'[date])) 

hope helps.

but, please consider create date table, idea, use relationships, makes expanding/collapsing part of dax easier.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -