Forum Discussion
New column with value from previous (last) date
Hi guys,
can someone please help me with this issue:
I would like to have in another column product flag from previous date (not DAY-1, but last previous)
I've found a solution for similar problem:
Previous Day Sales =
CALCULATE(
SUM(Table2[Sales]),
LASTDATE(
FILTER(
ALL(Table2[Date] ),
Table2[Date] < EARLIER([Date])
)
),
ALLEXCEPT(Table2,Table2[Store ID])
)
but I have two variables: ID and vendor
Can you please help me to achieve a solution like in Column E?
| Date | ID | Vendor | Product flag |
| 19.09.2022 | 1 | A | 1 |
| 19.09.2022 | 1 | B | 0 |
| 19.09.2022 | 1 | C | 0 |
| 20.09.2022 | 2 | A | 0 |
| 20.09.2022 | 2 | B | 1 |
| 20.09.2022 | 2 | C | 1 |
| 21.09.2022 | 3 | A | 1 |
| 21.09.2022 | 3 | B | 1 |
| 21.09.2022 | 3 | C | 1 |
| 22.09.2022 | 4 | A | 1 |
| 22.09.2022 | 4 | B | 0 |
| 22.09.2022 | 4 | C | 1 |
5 Replies
- Greg_Deckler
Community Champion
gwaczoka Try:
Column = VAR __Date = [Date] VAR __Vendor = [Vendor] VAR __Last = MAXX(FILTER('Table2',[Date] < __Date && [Vendor] = __Vendor),[Date]) VAR __Result = MAXX(FILTER('Table2',[Date] = __Last && [Vendor] = __Vendor),[Product flag]) RETURN __Result- gwaczokaRegular Visitor
Hi Greg,
thank you for the response and sorry for late reply.
It doesn't work, because there is no information about ID of the product included π
It is in the second column, might looks like hidden- AnonymousNot applicable
Hi gwaczoka,
Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
- gwaczokaRegular Visitor
Hey, can anyone please help? π