Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculating difference/change from the previous date or version.

Hi, 

 

I'm struggling finding the difference of value between dates. They are irregular and aren't monthly or yearly. 

 

My desired outcome would be a measure that calculates difference and change of the value.

 

something that looks like difference column

 

thanks

Coderegiontest datescoredifference
AUS05/07/19900
AUS09/08/1913040
ACA10/07/19500
BUS05/07/19800
BUS09/08/1970-10
BCA10/07/19750
  • Anonymous , Try as new columns

    last date = maxx(filter(Table, Table[Code] = earlier(Table[Code])&& Table[region] = earlier(Table[region]) && Table[Date] < earlier(Table[Date])),Table[Date])
    
    difference = Table[score] - maxx(filter(Table,  Table[Code] = earlier(Table[Code])&& Table[region] = earlier(Table[region])  && Table[Date] = earlier(Table[last date])),Table[score])
    
    

     

    As new measures

    Last Day Non Continous = CALCULATE(sum('Table'[score]),filter(all('Date'),'Date'[Date] =MAXX(FILTER(all('Date'),'Date'[Date]<max('Date'[Date])),'Table'['DAte'])))
    
    Change = sum('Table'[score])- [Last Day Non Continous]
    

     

2 Replies

  • Anonymous , Try as new columns

    last date = maxx(filter(Table, Table[Code] = earlier(Table[Code])&& Table[region] = earlier(Table[region]) && Table[Date] < earlier(Table[Date])),Table[Date])
    
    difference = Table[score] - maxx(filter(Table,  Table[Code] = earlier(Table[Code])&& Table[region] = earlier(Table[region])  && Table[Date] = earlier(Table[last date])),Table[score])
    
    

     

    As new measures

    Last Day Non Continous = CALCULATE(sum('Table'[score]),filter(all('Date'),'Date'[Date] =MAXX(FILTER(all('Date'),'Date'[Date]<max('Date'[Date])),'Table'['DAte'])))
    
    Change = sum('Table'[score])- [Last Day Non Continous]
    

     

  • AllisonKennedy's avatar
    AllisonKennedy
    Icon for Community Champion rankCommunity Champion
    You could try doing this as a column using EARLIER and RANK if you want the difference between the current and previous date for each Code > Region.