Export & Filter

Hi,
I’m learning MongoDB & dashboard charts.
Can I, and how, filter a chart by a user? I mean, I have a website and I wish to show certain results only for the user logged.
The user is a field in the documents that generate the charts, obviously.
For example, we create a chart for historical taxes for all users and past years. This chart is embedded into the website with an iframe. I wish to show only the data for the user logged.
I hope I explain.
Thanks
BTW, GREAT tool and GREAT database engine.

Hey Felipe -

I’m glad you’re enjoying Charts! Yes it is possible to do what you are looking for. Please take a look at this documentation page for details.

When the information you are showing is not sensitive, you can just pass the filter in as an iframe parameter. However if the information is sensitive (which I’m assuming is true in your case), you need to use the method described under “Inject User-Specific Filters”. This requires using the Embedding SDK and Authenticated Embedding to make it secure.

HTH
Tom

1 Like

Thanks. Allways the error is
{“errorCode”:7,“simple”:“Error loading data for this chart (error code: 7).”,“verbose”:“Error loading data for this chart (error code: 7). User filter is not allowed. See https://dochub.mongodb.org/core/charts-embedding-error-codes for details.”}
The filter, AppealYear, is set into the chart filter.
MongoDB Charts{ $match : { AppealYear : 2019 } }

Hi Felipe -

I think this is failing because you are specifying $match in your filter. This is implicit; you should just use the body of the match filter, e.g:
https://charts.mongodb.com/charts-retm-statistics-fouqe/embed/charts?id=XXXX&theme=light&filter={ AppealYear : 2019 }

Tom

Hi Tom
Stil {“errorCode”:7,“simple”:“Error loading data for this chart (error code: 7).”,“verbose”:“Error loading data for this chart (error code: 7). User filter is not allowed. See https://dochub.mongodb.org/core/charts-embedding-error-codes for details.”}
MongoDB Charts{AppealYear : 2019}

:frowning:

Can you share the chart id? Privately if you want: tom.hollander at mongodb.com.

Thanks. Fixed