We have a use case where we need to be able to ove...
# gooddata-ui
p
We have a use case where we need to be able to override a set of filters on a GoodData insight, we use the gooddata-sdk-ui-ext library. We have a baked in filter at the GoodData level and we want to keep what is set in GoodData already but add on to it using a single in. Right now, the way we have it set up, we use the InsightView React component and pass in a list of filters like so <*InsightView* insight={insight.insight_id} filters={insight.filters} config={insight.config} /> Where insight.filters is a array of positiveAttributeFilters What we need to be able to do is to essentially “override” the existing filters to pass in an filter Current curl --location --request POST 'https://<host>/api/actions/workspaces/<workspace>/execution/afm/execute' \ --header 'authority: <host> \ --header 'accept: application/json, text/plain, */*' \ --header 'accept-language: en-US,en;q=0.9' \ --header 'authorization: Bearer <REDACTED TOKEN>' \ --header 'content-type: application/json' \ --data-raw '{ "resultSpec": { "execution": { "filters": [ { "positiveAttributeFilter": { "label": { "identifier": { "id": “CountryCode, "type": "label" } }, "in": { "values": [ “*BAKEDINFILTERVALUE*” ] } } }, { "positiveAttributeFilter": { "label": { "identifier": { "id": "FinancialInstrument.TenantFinancialInstrumentId", "type": "label" } }, "in": { "values": [ “*VALUE WE ARE TRYING TO ADD TO IN ABOVE*” ] } } }, ], "auxMeasures": [] }, "settings": {} }' Desired curl --location --request POST 'https://<host>/api/actions/workspaces/<workspace>/execution/afm/execute' \ --header 'authority: <host> \ --header 'accept: application/json, text/plain, */*' \ --header 'accept-language: en-US,en;q=0.9' \ --header 'authorization: Bearer <REDACTED TOKEN>' \ --header 'content-type: application/json' \ --data-raw '{ "resultSpec": { "execution": { "filters": [ { "positiveAttributeFilter": { "label": { "identifier": { "id": “CountryCode, "type": "label" } }, "in": { "values": [ “*BAKEDINFILTERVALUE*”, “*VALUE WE ARE TRYING TO ADD*” ] } } }, ], "auxMeasures": [] }, "settings": {} }' Does the gooddata-sdk-ui-ext library provide a way to accomplish what we need ?
j
i
This could promising if we can get this working with the React component @Phanindra mentioned.
is there a prop we can pass to <InsightView /> to take advantage of this MAQL feature?
p
@rohit mathur see ^
v
@Joseph Heun - do you have an answer to the above question?
j
Hi Vivek, it is still being discussed what can be done. We will follow up as soon as we have more details
p
Thanks @Joseph Heun
d
Hi @Phanindra currently the
filters
prop of the InsightView component only takes filters to be applied in addition to the filters already specified on the saved insight object. The easiest solution I can think of is to remove any filters on your saved insight (or create a copy of the original for the embedding purpose) and set the filters using the
filters
prop. Does that work for you?
i
Hi @Dan Homola — thank you for your reply. Let me see if I can provide a bit of an example to elucidate what we are after. We actually are trying to do exactly what you mentioned — add new filters in addition to what filters are already saved on the insight. I think the trouble is that the filters are being combined in an unexpected way. Here is a stripped down example: Say my insight already has a filter on “Country”, similar to “WHERE Country IN [“USA”]“. So now, say I want to add an additional filter such that I have something like “WHERE Country in [“USA”, “CANADA”]” If I add a new “CANADA” filter as a prop, my result is something like: “WHERE Country in [“USA] AND Country in [“Canada”]“, which of course will always give me a null set because it expects Country to be 2 different things simultaneously. I suppose the way I’d expect to combine these 2 filters (if not just combining their “in” arrays) would be to OR them together instead of ANDing them, like: “WHERE Country in [“USA”] OR Country in [“Canada]” Hopefully that helps explain our issue — is there a way to do what we’re after there?
d
Hi @Igor Strupinskiy thank you for the details. Unfortunately “OR-ing” is not supported by the InsightView. What you can do in your example though is to remove the Country filter in your insight and call your InsightView with filter for IN [“USA”, “Canada”]. In other words: specify the filters only via the
filters
prop if the InsightView. Then you would see Canada and USA.