Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
HI,
I have a column with dates and values. The date column is not including some days, so I need to create a column with the value of the previous date like this one (Also the table has an ID column with different ID's
Date | ID | Value | Result |
01/01/2020 | ABC | 100 | - |
02/01/2020 | ABC | 200 | 100 |
5/01/2020 | ABC | 150 | 200 |
06/01/2020 | ABC | 110 | 150 |
08/01/2020 | ABC | 300 | 110 |
Thanks for the help
Agus
Solved! Go to Solution.
Hi @Anonymous ,
Check the formula below.
Column =
var pre_date = CALCULATE(MAX('Table'[Date]),FILTER(ALLEXCEPT('Table','Table'[ID]),'Table'[Date]<EARLIER('Table'[Date])))
return
CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])&&'Table'[Date]=pre_date))
Result would be shown as below.
For earlier() function please check the below document.
https://docs.microsoft.com/en-us/dax/earlier-function-dax
Best Regards,
Jay
@Anonymous , Try a new column
New column =
var _min = maxx(filter(Table, [ID] = earlier([ID]) && [Date] <earlier([Date])),[Date])
return
maxx(filter(Table, [ID] = earlier([ID]) && [Date] =_min),[Result])
I dont understand two things of your DAX:
- Earlier[ID] ?
- [Result]?
Thanks
Hi @Anonymous ,
Check the formula below.
Column =
var pre_date = CALCULATE(MAX('Table'[Date]),FILTER(ALLEXCEPT('Table','Table'[ID]),'Table'[Date]<EARLIER('Table'[Date])))
return
CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[ID]=EARLIER('Table'[ID])&&'Table'[Date]=pre_date))
Result would be shown as below.
For earlier() function please check the below document.
https://docs.microsoft.com/en-us/dax/earlier-function-dax
Best Regards,
Jay
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
90 | |
87 | |
84 | |
66 | |
49 |
User | Count |
---|---|
131 | |
110 | |
96 | |
70 | |
67 |