Hi all, I have a table of products and the simplif...
# gooddata-platform
p
Hi all, I have a table of products and the simplified version of it (for here) can be in either of two formats, the first column is a the product_id and the second column is related_product_ids. The table can either have an array of related_product_ids such that the table would look like this: | ---product_id--- | --- related_product_ids --- | | prid123 | [prid345, prid567] | | prid345 | [prid123, prid567] | | prid567 | [prid345, prid123] | ... etc. Or it can be in a long format so each row has 1 product in each column and each product can have many rows such as: | ---product_id--- | --- related_product_ids --- | | prid123 | prid345 | | prid123 | prid567 | | prid345 | prid123 | | prid345 | prid567 | | prid567 | prid123 | | prid567 | prid345 | ... etc. I am having trouble figuring out how to make something like this work with filters in GoodData if it were to be joined to some metric like product_views and say I wanted to filter all related products without having to choose each one individually and also without duplicating rows etc. For example say I wanted to see all product_views for prid123 and related products then I could just select that one and it would show the product_views for prid123,prid345,prid567 because they are all related. Apologies for the long question, hopefully it makes sense.
i
Hi Peter, This is actually affected by your logical data model and the way it was created. Do these attributes belong to one dataset, or do they belong to two separate datasets?
m
Hi Peter, In this case I believe you would need to use two separate attributes (or whole dimensions) to achieve this. And then you can utilize the native M:N relation in GoodData model. For that you would use the second version of the table - with multiple rows for multiple related products. You would have one
product
attribute as the standard one and to that one all the
product views
will be tied. And then you would map your table as another dataset “`related products`” and connect it to your
product
dataset with a M:N relation. If you then filter by the
related product
attribute, the double-sided M:N arrow will cause this filter will get applied to
product
and from there the filter will get propagated normal way to
product_views
. If you also want to see values for the selected product, not just its related ones, you might need to add each product as its own related product into your table. And you can still filter with the attribute
product
to get values for just the selected produtcs, not their related ones. You can read more about the native M:N relation in GoodData model here (assuming you are using the GoodData Platform edition. If you happen to use the newer GoodData Cloud, you can read relevant info here). I hope this helps.
🙌 1
p
Thank you both, we can modify the dataset as required so same or separate datasets (I was thinking separate). I wasn't aware there was an M-N relation available in GD, I will test that out and see how it goes. It looks like it should work 🤞
🤞 1