Creating views in loop

Hello!

I’m completely new to Looker, and have just about one week of experience. So, if the questions seems obvious, I’m sorry.

For my project, I have transaction data at product level. For each of the distinct products, I need to create a BQ ML model.

Now I’ve figured out how to do that for each individual product, mainly following along this. But this is not really scalable, because I can not really write the same thing for 2K+ different products, only change being the change in filter for product codes.

I’ve figured out that this is probably possible only if we can create multiple derived tables for each product ,similar to if I write manually, but with Liquid. But the problem is I cannot find any example to use Liquid at a higher level than view, so not sure whether that is possible or not.

So, these are essentially my requirements:

  1. get the list of different products (easily doable by SQL)
  2. run a loop over it to create a model for each product
  3. store the models in different PDT’s with varying view names (probably can be done using append in Liquid)

As you can see, I sort of know first and last steps, but the second one is what completely baffles me. I know the SQL query I will be needing, but how to execute that and save in a view with pre-defined name via Liquid loop is my question.

I hope my question makes sense, and someone of you will be able to help me out. Thanks a lot in advance!

0 2 383
2 REPLIES 2

Former Community Member
Not applicable

.

Hi again!

Can I get some replies please? Some hints at the right direction would be enough, detailed snippets not necessary.

I’ve started to consider that it may actually be impossible through from looker/liquid combination only, as I could not find a way to store the results of distinct products (select distinct call to BQ). But that may be due to my unfamiliarity as well, so hoping for some confirmation from the experts.

Thanks.

Top Labels in this Space
Top Solution Authors