Forum Discussion
next day lookupvalue in the same table
Hi.
I have a DailyTableId with all the ProductId which are active in my ecommerce each day. For instance:
Date | ProductId
01/01/2020 | 4r
01/01/2020 | 1a
01/01/2020 | 3b
02/01/2020 | 4r
02/01/2020 | 1a
02/01/2020 | 3b
03/01/2020 | 4r
03/01/2020 | 3b
04/01/2020 | 4r
04/01/2020 | 1a
04/01/2020 | 3b
DailyTableId was created from Calendar and ProductId which contains ProductId, ActiveFrom and LastDayActive.
I am trying to create a new column to find out if every productId was active the day after. So the desire result would be:
Date | ProductId | Previous Day Active
01/01/2020 | 4r | 1
01/01/2020 | 1a | 1
01/01/2020 | 3b | 1
02/01/2020 | 4r | 1
02/01/2020 | 1a | 0
02/01/2020 | 3b | 1
03/01/2020 | 4r | 0
03/01/2020 | 3b | 1
04/01/2020 | 90r | 0
04/01/2020 | 7a | 0
04/01/2020 | 3b | 0
1 means that the ProductId is Active on next day and 0 means that it is the last day which the product is Active.
May anyone help me please?
Thanks
aramirez2 , if, it is continous date , new column like
isblank(countx(filter(Table,Table[Date] =earlier(Table[Date])+1 && Table[ProductId] =earlier(Table[ProductId])),Table[Date]),0,1)
noncontinous
new column =
var _max =minx(filter(Table,Table[Date] >earlier(Table[Date]) && Table[ProductId] =earlier(Table[Date]))
return
isblank(countx(filter(Table,Table[Date] =_max && Table[ProductId] =earlier(Table[ProductId])),Table[Date]),0,1) //ProductIdFor a noncontinuous date. refer this for both column and measure
2 Replies
- amitchandak
Super User
aramirez2 , if, it is continous date , new column like
isblank(countx(filter(Table,Table[Date] =earlier(Table[Date])+1 && Table[ProductId] =earlier(Table[ProductId])),Table[Date]),0,1)
noncontinous
new column =
var _max =minx(filter(Table,Table[Date] >earlier(Table[Date]) && Table[ProductId] =earlier(Table[Date]))
return
isblank(countx(filter(Table,Table[Date] =_max && Table[ProductId] =earlier(Table[ProductId])),Table[Date]),0,1) //ProductIdFor a noncontinuous date. refer this for both column and measure
- aramirez2
Helper I
amitchandak Thanks a million! your formula is correct. Just you forgot "IF" at the beginning.
Regards