Second Question: I have numeric "Attributes" such...
# gd-beginners
p
Second Question: I have numeric "Attributes" such as ID's that will get displayed in some contexts...These being defined as attributes seems to work OK, except for Sorting, which seems to sort the value alphabetically rather than Numerically ? How to I get a Numeric Attribute to sort properly? (Running Community Edition against Snowflake)
m
Hi Paul, I have been running some tests in my GD CN project and have working with numeric “Attributes” as ID’s, but the Numerically ID’s are sorting correctly - can you please provide some examples of the ID’s you’re working with, or perhaps some screenshots?
j
p
Label sorting is interesting, thanks. per Michaels comment, I need to dig a bit deeper into how my DW is configured and validate the type.
I have verified that there is a sorting issue with Numeric Attributes: Datatype of field in Snowflake is Number:
Value in a FILTER is being sorted by Snowflake and appears correctly in Numeric order: Snowflake Query:
Copy code
SELECT "BASELOANAMOUNT" AS "a_label_baseloansexport_baseloanamount_fa5fce94_c3637969d8cabf", 1 AS "m_1"
FROM "CONTENT"."BASELOANSEXPORT"
GROUP BY "BASELOANAMOUNT"
ORDER BY "BASELOANAMOUNT"
FETCH NEXT 10000 ROWS ONLY
Result is sorted correctly:
However, in the visualization itself, Sorting was NOT issued to the Snowflake Query, but appears to be handled by GoodData, incorrectly: Snowflake Query(note ORDER BY is not present):
Copy code
LECT "a_label_baseloansexport_baseloanamount_fa5fce94_5a4bf2201a10ab" AS "a_label_baseloansexport_baseloanamount_fa5fce94_c3637969d8cabf", "m_c4806a87a3809f074c7f20662a69d3f9" AS "m_1"
FROM (SELECT "BASELOANAMOUNT" AS "a_label_baseloansexport_baseloanamount_fa5fce94_5a4bf2201a10ab", COUNT("LOANID") AS "m_c4806a87a3809f074c7f20662a69d3f9", TRUE AS "def_m_c4806a87a3809f074c7f20662a69d3f9"
FROM "CONTENT"."BASELOANSEXPORT"
GROUP BY "BASELOANAMOUNT") AS "t1"
WHERE "def_m_c4806a87a3809f074c7f20662a69d3f9" AND "a_label_baseloansexport_baseloanamount_fa5fce94_5a4bf2201a10ab" IN ('10', '100', '10000', '10200', '13450', '300')
Resulting visualization Alpha sorted:
@Michael Ullock See screenshots and corresponding details above.
j
@Paul Muharsky When reports are executed, ORDER BY is not a part of the query. Honestly, we are fighting internally about this capability 😉 It is caused by the potential need of cross tabulating (pivoting) the result - it is possible to sort by pivoted attributes and in this case you can imagine that sorting by ORDER BY of raw result (before pivoting, which happens in GoodData) is not feasible. Anyway, GoodData part of the execution should sort results correctly, if you set the sort column correctly. Can you share a screenshot of how the related dataset is configured in LDM Modeler application?
p
In this case, I just pulled a table in from snowflake. No special configuration, no changes. here is the Attribute Defintion as defined in the Export FIle:
Copy code
{
  "id": "BASELOANSEXPORT.BASELOANAMOUNT",
  "title": "Baseloanamount",
  "description": "Baseloanamount",
  "labels": [],
  "tags": [
    "Baseloansexport"
  ],
  "sourceColumn": "BASELOANAMOUNT"
}
It's unclear on what attribute / Label I would use for sorting, as I have no customizations or label groupings of any kind here.
j
Unfortunately it seems that this feature is not exposed to the UI app yet. I encourage you to check OpenAPI specification, either in our DOC or in you running env, e.g. localhost:3000/apidocs. DOC: https://www.gooddata.com/developers/cloud-native/doc/2.0/api-and-sdk/api/api_reference_all/#/layout/setLogicalModel There is field
sortColumn
on attribute level, which should provide the requested functionality.
p
I'm unclear on how this would be of benefit? What value would you suggest I add to this to tell it that this is a number and needs to be sorted that way? The Sort column here would be exactly the same as the Source Column ...is that not the default? if setting the Sort Column to the same as the source column changes functionality, what are the defaults for these attributes?
j
What type of source field is indicated in mapping section of dataset details (Data -> View details -> Data mapping)? Could it be that the type was originally STRING when data model has been scanned? Could it be that data type has been changed but result of report comes from a cache? Maybe you can try to clear caches using instructions from documentation and update model by scanning data source to update the data types. The fact that the filter is ordered numerically but the result in insight is ordered alphabetically is suspicious. It may be a bug but I suggest to check how data type has been captured in the data model and if it can be caused by data type change without cache invalidation.
p
Data type is INT according to the mappings.
as noted above, the Filter sorts correctly because Snowflake is handing the sort....the sort for the actual insight is not part of the query being submitted to Snowflake. Filter OK, data in the background is the alpha sorted Insight for this value.
j
Thank you. I have reported it as bug.
p
Thanks!
j
Thanks @Jakub Sterba and sorry for confusion. It will be fixed in the next release.