You could land up with very poor performance doing this sort of processing in the front end. I would explore adding some processing to the load script. I assume that the 'correct' tariff is not subject to user selections, and if that is the case, you could calculate the tariff during the load process.
You would probably need a master calendar with all the dates in the date range of interest and you could apply the product names and tariffs to the calendar using an interval match, creating a date/product/tariff table with the tariff 'from' and 'to' dates. You could then flag the tariffs that have the lowest duration and you could use a set expression in the front end to select the 'correct' tariffs.
I can only give these general guidelines unless you can post some sample data and your qvw.