Reputation: 25
I have a problem getting the right "Price" for a product based on Effectivity date. I've checked on StackOverFlow but on Google Sheet is not mentioned
I need a table of Effective Price table
after querying Price change history table
Please help me solve this problem
Thanks
Upvotes: 1
Views: 309
Reputation: 15328
=query(A:C,"select B,C where A='"&E3&"' and C<=DATE'"&TEXT($E$1,"yyyy-MM-dd")&"' order by C desc limit 1",0)
=arrayformula(iferror(vlookup(unique(A2:A),query(A2:C,"select A,B,C where C<=DATE'"&TEXT($E$1,"yyyy-MM-dd")&"' order by C desc ",0),{1,2,3},0)))
=sort(arrayformula(iferror(vlookup(unique(A2:A),
{query(A2:C,"select A,B,C where C<=DATE'"&TEXT($D$1,"yyyy-MM-dd")&"' order by C desc ",0);
query(A2:C,"select A,' ','-' where A is not null ",0)},
{1,2,3},0))))
Upvotes: 2
Reputation: 5862
Formula in E3
=QUERY(A:C,"select A,max(C) where C <= date '"&TEXT(E1,"yyyy-MM-dd")&"' and A is not null group by A label A '',max(C) ''",1)
Formula in G3
=ArrayFormula(VLOOKUP(E3:E&F3:F,{A:A&C:C,B:B},2,FALSE))
If you want to have the same sequence of columns as yours, you need 3 formulas.
Upvotes: 0