Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
Can you please help me understand how to resolve below
| ID | Name | Date | Product |
| 123 | John | 1/1/2023 | TV |
| 234 | John | 2/1/2024 | TV |
| 345 | John | 2/2/2024 | TV |
| 456 | John | 3/4/2024 | TV |
| 567 | John | 3/6/2024 | Speaker |
I have to create two columns in above table with two conditions
Condition 1 - If John buying TV after one year from initial purchase and the next purchase after one year from last purchase then its New purchase but if he changes Product like Speaker in the same Year then its New ,if not Existing - Always initial purchase is New
Condition 2 - If John buying TV or Speaker after one year from initial purchase and the next purchase after one year from last purchase then its New purchase if not Existing - Always initial purchase is New
Results Like below
| ID | Name | Date | Product | Condition 1 | Condition 2 |
| 123 | John | 1/1/2023 | TV | New | New |
| 234 | John | 2/1/2024 | TV | New | New |
| 345 | John | 2/2/2024 | TV | Existing | Existing |
| 456 | John | 3/4/2024 | TV | New | New |
| 567 | John | 3/6/2024 | Speaker | New | Existing |
Thanks in Advance!
Hi look into this,
LOAD
ID,
Name,
Date(Date#(Date, 'M/D/YYYY')) as Date,
Product,
If((Date - Previous(Date)) >= 365, 'New', 'Existing') as New/Existing,
// Condition 1
If(RowNo()=1, 'New',
If(Product <> Previous(Product) and Year(Date)=Year(Previous(Date)), 'New',
If(Year(Date)-Year(Previous(Date)) >= 1, 'New', 'Existing'))
) as [Condition 1],
// Condition 2
If(RowNo()=1, 'New',
If(Year(Date)-Year(Previous(Date)) >= 1, 'New', 'Existing')
) as [Condition 2]
Resident YourTable
Order By Name, Date;