I have a calculated field called FirstSale where I observe the first instance of a product that sells more than 80% of its inventory.
I look at the product ID and the timestamp (converted to string) and the % of inventory sold.
How can this query be optimized to not depend on this many fields OR how can this be converted to a SQL query.
Calculated Field Logic:
IF STR[SaleDate]) =
{FIXED [ID], {FIXED [ID], STR([SaleDate]), [Inventory %]:
IF MIN([Inventory %]) > 0.8
THEN 1 ELSE 0 END}: MIN([STR(SaleDate]))}
THEN 1
END
The data looks like this
Where there is a product ID, Sale Date, Inventory % and the last column (with 1s and 0s) is the calculated field.
Essentially, The goal is that the calculation should return 1 only for the first time a an ID shows Inventory % > 80%. In all other cases, return 0.
For example looking at the second ID, the only value combination that should have a 1 is October 28 (2020083008056, October 28 2020, 84.00%, 1 ) and all other values should return 0.
So the full return for the second ID would be
(2020083008056, October 28 2020, 84.00%, 1 )
(2020083008056, October 29 2020, 84.36%, 0 )
(2020083008056, October 30 2020, 84.67%, 0 )
(2020083008056, October 31 2020, 84.67%, 0 )