Hello, I had a question concerning what is the pro...
# gooddata-cloud
k
Hello, I had a question concerning what is the proper way to query the distinct values of an attribute/dimension using the SDK (from the front-end )? I am getting the feeling that the custom executions (using sdk-backend-tiger and sdk-model) are not meant for that, but rather for computing measures, and slicing it and filtering using dimensions. My intention is to setup a filter in the frontend using those values.
j
Hi Karim, May I ask about the SDK version that you are currently using and mainly about the use-case of this implementation? I understood you would like to filter out a particular value in the filter via SDK but can you please confirm the reason behind this in context of your setup?
k
Hi @Julius Kos, thanks for your help. I am using sdk-backend-tiger version 10.15.0. But I think you misunderstood my question, my use case is fairly simple: I am trying to get all the values of an attribute as raw data.
What I want to do with this raw data is to create a custom filter in the front end. So I don't want a GoodData filter, but only the raw data. Then I will perform a custom execution with a filter on this attribute.
j
Hi Karim, Thank you for the additional information. I am not an expert on SDK but I will pass your question to our Technical Team. One of the team members will get back to you once available.
k
Okay thank you @Julius Kos
f
Hi @Karim Sabaa, in this case I would certainly suggest looking at our GD.UI article Get Raw Data - there are some interesting suggestions there for grabbing the data you need by running a report computation directly from the SDK. Another option is to use our APIs directly, as outlined in Access Raw Data Through API, or even via the Python SDK’s get_label_elements. Please have a look at these resources and let me know if that’s more or less what you’re looking for 🙂
k
Hi @Francisco Antunes, thanks for your suggestions. I have previously read those articles, but still couldn't find a direct way to do it using the GD.UI. Could you please provide a simple code example for getting a label's elements using GD.UI ? Thank you 🙏 Nice to know that we can do this easily using Python, but would be good if I can also do this directly from the UI.
@Francisco Antunes this is the best that I could come up with, but it looks quite ugly:
Copy code
let labelValues = await backend
    .workspace("workspace_id")
    .execution()
    .forItems([Md.Label])
    .withDimensions(newDimension([Md.Label]))
    .execute()
    .then(result => result.readAll())
    .then(result => result.headerItems[0][0].map((item) => item['attributeHeaderItem']['name']));
👀 1
any updates please ?
f
Hi Karim, sorry for the delays. I’ve conferred a bit with some colleagues, and although it looks a bit ugly, as you said, that looks functional and is most likely how such a snippet would work. You see, GD.UI isn’t particularly suitable for this type of task by design, so some level of inelegance is to be expected, so to speak. 🙂 But it does work, right?
👍 1
k
No worries, thanks for your help 👍 It does work, I was just expecting a simpler way for what I imagine being a common use case.
f
That make complete sense, I understand. Glad it works, though! 🙂
🙏 1