Knowledge Drop

Why is there an extra field selected (and grouped) in my SQL?


Userlevel 5

Last Tested: Aug 3, 2018

 

Also asked as "Why do additional (extra) fields show up in the Select list and Group by when they have not been selected in the Explore"?

This will happen if another field is referenced in a html or link parameter.

Example:

measure: recalls_percent {

type: percent_of_total

sql: ${count} ;;

link: {

label: "{{make._value}} Details"

url: "/dashboards/106?Make={{make._value}}"

}

}

 

Generated SQL when only this measure is selected (note that my_table.MAKE is added to the query)

SELECT

my_table.MAKE AS my_table_make,

(COUNT(CASE WHEN (UPPER(my_table.TYPE ) = UPPER('RECALL')) THEN 1 ELSE NULL END)) AS my_table_recalls_percent

FROM my_table

 

Short answer, yes, because we need to populate the values for that link.

Note: this is true of both link parameter and html

The solution is to create additional measures with or without the link as needed to avoid the additional GROUP BY

 

This content is subject to limited support.                

 


0 replies

Be the first to reply!

Reply