We have two separate explorers based on each view. When we execute the explorers, we get the correct result when using the time dimension for each one of them. Now, it has been requested to implement another metric, which is a combination of the basic ones:
Total_Value_C = Total_Value_A + Total_Value_B
Is it possible to achieve something like this in LookML? What could be the right approach, especially considering that each measure is based on a different time dimension?
At the end of the day, it shouldn’t matter what time dimension each measure is based on. In Looker, you can select any measure and group it with any dimension, so measures aren’t really based on any dimension. Of course, if I’m missing something about your use case, please let me know!
Hello @sam8 thanks for you reply. The definition of the metric is clear, no doubt in that. However, the question is, what is the relation that we need to create between the two original views? Because it should be available for the user to filter the period of time for both metrics. That is where we are struggling with the code.
Now, this measure will work for any explore where you have joined in both view_A and view_B.
If you want to use view_A in an explore without view_B, then you can use the fields parameter to remove Total_Value_C, so that you don’t get a LookML error when the validator goes to look for the reference to view_B. You can [exclude the field](http://Exclude%20the field that is causing the error from Explores) with LookML like this:
explore: view_Z { # This explore joins view A but not view B
fields: [ALL_FIELDS*, -view_A.Total_Value_C] # Exclude view_A.Total_Value_C
join: view_A {
...
}
}
Would it be possible to create a derived table, where all 3 of the views are joined, and then create a custom measure inside of that derived table (which you would then join into your model)? That is what I would do!
You can create a standalone view for cross-view measures. One advantage of storing cross-view measures in standalone views is that your Explore won’t break if you don’t include both views in your Explore. For example, in @sam8 's latest reply, the Explore would break if view_B is not joined.