Bigquery/Python: SQL Logic for identifying table direction using a column
Consider below approach
select *,
case div(cast(angle - min(if(angle = 360, 0, angle)) over(partition by store, aisle) as int64), 90)
when 1 then 'Right'
when 2 then 'Back'
when 3 then 'Left'
else 'Front'
end as direction
from your_table
if applied to sample data in y our question - output is