Forum Discussion

aramirez2's avatar
aramirez2
Icon for Helper I rankHelper I
6 years ago
Solved

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

2 Replies

  • 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) //ProductId

     

    For a noncontinuous date. refer this for both column and measure

    https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c3243d1f9

    • aramirez2's avatar
      aramirez2
      Icon for Helper I rankHelper I

      amitchandak  Thanks a million! your formula is correct. Just you forgot "IF" at the beginning.

       

      Regards