Sorting & paging

  • 17 July 2017
  • 8 replies

I am having trouble getting sorting to work, also is there anyway to page results ?'' + REACT_APP_LOOKER_KEY + '&client_secret=' + REACT_APP_LOOKER_SECRET)

.then(response => {

var lookerToken =

var vin = '123'
var firstName = 'john'
var lastName = 's'

var vinWildCard = encodeURIComponent(`%${vin}%`)
var firstNameWildCard = encodeURIComponent(`%${firstName}%`)
var lastNameWildCard = encodeURIComponent(`%${lastName}%`)

var sort = ''

var limit = 10;

var queryString = `,inventory_table.year,sales_table.customer_first_name,sales_table.customer_last_name&f[]=${vinWildCard}&f[sales_table.customer_first_name]=${firstNameWildCard}&f[sales_table.customer_last_name]=${lastNameWildCard}&sorts={sort}&limit=${limit}&access_token=${lookerToken}`;

var time =


console.log(`query took ${ - time}`)



8 replies

Userlevel 3

Hey there @emmett!

I see a couple of things in your code snippet that could be causing the problems you’re having, but rather than take a shot in the dark, can you repost the error that you’re getting in its entirety?


I am not getting any errors, my attempts at sorting simply returns same results every time whether I use asc/desc or different dimension names.

No idea how to page either

Userlevel 3

@emmett This might be silly but are you missing a $ in front of the sort object you’re trying to interpolate into that string?

... &sorts={sort}&limit=${limit} ...

oh good spot, that solved it 🙂

2 more questions if I may

1 what does the 0 mean in the . sort: sales_table.customer_first_name desc 0

2. is there any way I can get the total results back in the results so that i can subsequently page through them ?

Userlevel 3

I’m not actually sure. I tested it a bit on my end and adding/removing the 0 or 1 or whatever after the sort definition doesn’t really do anything. It didn’t change the query at all and it even used the same cache key, so I think that might just be a mistake.

thanks, got any advice on paging ?

Userlevel 3

I don’t think we support paging for API requests right now, but I can talk to our Product team about building in support for this. Maybe just a bool parameter?

I think we are going for an alternative approach now, but in general if you were to add paging you would need to accept ‘page’ and ‘max’ params e.g. page=2&max=10

so if 1000 results in whole pageable dataset then page=2&max=10 would retrieve results 10-19