Forum Discussion
MF_BI
4 years agoRegular Visitor
Flag Period
Hello all,
I have this kind of table below :
| Order date | id | first use date |
| 11/01/2021 15:18 | id1 | 11/01/2021 10:11 |
| 11/01/2021 10:11 | id1 | 11/01/2021 10:11 |
| 12/01/2021 12:53 | id1 | 11/01/2021 10:11 |
| 09/02/2021 15:18 | id1 | 11/01/2021 10:11 |
| 15/03/2021 14:54 | id1 | 11/01/2021 10:11 |
| 15/04/2021 14:37 | id1 | 11/01/2021 10:11 |
| 17/05/2021 10:42 | id1 | 11/01/2021 10:11 |
| 01/06/2021 12:16 | id1 | 11/01/2021 10:11 |
| 07/01/2021 08:53 | id2 | 07/01/2021 08:53 |
| 06/02/2021 11:47 | id2 | 07/01/2021 08:53 |
| 11/03/2021 11:16 | id2 | 07/01/2021 08:53 |
and I want to add column with Flag, that indicate by users id if the order date is in the first month after first use (First use date+30days), or in the second the seconde month(Between First use date+30 and First use date+60), or in the third month(Between First use date+60 and First use date+90),etc... as the table below :
| Order date | id | first use date | Flag |
| 11/01/2021 15:18 | id1 | 11/01/2021 10:11 | M1 |
| 11/01/2021 10:11 | id1 | 11/01/2021 10:11 | M1 |
| 12/01/2021 12:53 | id1 | 11/01/2021 10:11 | M1 |
| 09/02/2021 15:18 | id1 | 11/01/2021 10:11 | M1 |
| 15/03/2021 14:54 | id1 | 11/01/2021 10:11 | M3 |
| 15/04/2021 14:37 | id1 | 11/01/2021 10:11 | M4 |
| 17/05/2021 10:42 | id1 | 11/01/2021 10:11 | M5 |
| 01/06/2021 12:16 | id1 | 11/01/2021 10:11 | M5 |
| 07/01/2021 08:53 | id2 | 07/01/2021 08:53 | M1 |
| 06/02/2021 11:47 | id2 | 07/01/2021 08:53 | M1 |
| 11/03/2021 11:16 | id2 | 07/01/2021 08:53 | M3 |
Thank you for your help. I appreciate that.
Best,
MF_BI Try:
Flag Column = TRUNC(DIVIDE(([first use date] - [Order date]) * 1.,30))+1
2 Replies
- Greg_DecklerCommunity Champion
MF_BI Try:
Flag Column = TRUNC(DIVIDE(([first use date] - [Order date]) * 1.,30))+1- MF_BIRegular Visitor
Thank you Greg_Deckler