aggregate-functions


Querying customDimensions in Google Bigquery


Can someone explain how to query customDimensions in bigquery?
My query works with a simple where clause i.e.
SELECT COUNT(DISTINCT fullVisitorId)
FROM GA_SESSION
WHERE hits.customDimensions.index = 4
AND hits.customDimensions.value = 'variable1'
AND hits.page.pagePath LIKE '%something%';
However now when I try to do an aggregates, or if I try EXACT_COUNT_DISTINCT without a group by, I get an error i.e.
SELECT date, COUNT(DISTINCT fullVisitorId)
FROM GA_SESSION
WHERE hits.customDimensions.index = 4
AND hits.customDimensions.value = 'variable1'
AND hits.page.pagePath LIKE '%something%'
group by date
Error is :
Query Failed
Error: Cannot query the cross product of repeated fields customDimensions.index and hits.customDimensions.index.
Those are repeated fields, and you need to FLATTEN them in order to query.
FLATTEN converts a repeated field into an optional field. Given one record with many values for a repeated field, FLATTEN unrolls it into many records, one record for each value of the (formerly) repeated field; any non-repeated fields become duplicated to fill out each of the new records formed. FLATTEN removes one level of nesting.
Read more about FLATTEN
You need to rewrite your query into:
SELECT .... FROM FLATTEN(FLATTEN(GA_SESSION,customDimensions),hits.customDimensions)

Related Links

rrdtool does not keep max
Tableau Aggregate Percentage
use aggregates (min, max, avg) in CONSTRUCT query [duplicate]
R: transposing and aggregating columns
SQL Query Aggregate Error
Usage of aggregate functions in MarkLogic
Querying customDimensions in Google Bigquery
NHibernate - QueryOver criteria appearing in Where instead in Having clause, error
Howto aggregate on full data set in Spring Batch jobs?
Creating an aggregate function fails
Necessity of declaration of function in c and cpp
Calculate window average in tableau
Complexity asymptotic relation (theta, Big O, little o, Big Omega, little omega) between functions
What are TOP_COUNT and TOP_MAXCOUNT in BigQuery?
marklogic need advise for approach to aggregate documents
multiply(num) aggregate function in postgresql

Categories

HOME
javafx
redux
gsm
openacc
cxf
dronekit
popover
ibm
nltk
query-string
download
mediarecorder
powerquery
uml-designer
pdf-generation
sitemap
webpack-dev-server
yacc
obd-ii
normals
angular-universal
ldap-query
android-notifications
web-testing
owncloud
k-means
template10
openam
jquery-easyui
glibc
xna
connectiq
opengraph
sha
adobe-captivate
android-6.0-marshmallow
bytebuffer
dynamics-ax-2012-r3
paper-trail-gem
language-detection
slim-lang
log4net-configuration
node-soap
leaderboard
scip
queryover
origami
gem-fury
office-interop
quartz
grails-2.0
gridgain
opos
g77
stanford-nlp-server
visio-2010
riemann
r-commander
kendo-scheduler
jtextarea
sqlproj
copy-constructor
ownership
computed-properties
gevent
optional-parameters
ldd
mate-desktop
tinybox2
cosign-api
syslog4j
csc
objectify
bytearray
weblogic-maven-plugin
nsoperationqueue
system-integration
supervised-learning
nd4j
instabug
markerspiderfier
google-finance-api
jcomponent
recode
android-filterable
dcg
targetprocess
opennebula
mathics
tigase
agent-based-modeling
serializer
parallel-port
scjp
rails-migrations
xpand
debuggervisualizer
hotlinking
power-management
elixir-framework
flask-mongoengine
misfire-instruction
infomaker
caroufredsel
kohana-orm
xrandr
pudb
architectural-patterns
reference-manual
setcookie
linqdatasource
metapost
netzke
doxia
github-archive
systrace
idtabs
parallel-python
flexbuilder
soapexception
mismatch
noise-reduction
coderush-xpress
disk-based
tracd

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App