Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
User | Count |
---|---|
77 | |
75 | |
46 | |
31 | |
28 |
User | Count |
---|---|
99 | |
93 | |
50 | |
49 | |
46 |