Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
57 | |
55 | |
55 | |
37 | |
30 |
User | Count |
---|---|
78 | |
64 | |
45 | |
43 | |
40 |