Hello, I’m quite new to Redash and I’ve been trying to find a way to visualize a query, where I use multiple group by’s e.g.

SELECT date, count(players)
FROM inapppurchase
WHERE date = ‘{{ date }}’
GROUP BY date, platform, gameversion, usertype

I would like the visualization to make separate lines for example based on both platform & usertype so lines would be:

  • Android guest,
  • Android registered,
  • iOS guest,
  • iOS registered.

I can get it to work on the table, but not in a graph.

I would also like to know how to use parameters with 0, 1 or multiple values? Let’s say as an example I want to keep my query on default showing the sum of all platforms, but I would like to have a parameter where I can tell the query to show

  • sum of all platforms (empty parameter)
  • only Android (parameter: Android)
  • both Android and iOS (parameter: Android, iOS)

Are these things possible?
Thank you for your time

Hi @M_Salenius!

Hope I understood your questions correctly :sweat_smile:

Try these solutions (probably you’ll need to combine/modify them to fit your needs, it’s just an example):

  1. Modify your query to concat paltform and user type into single field - it should become something like (PostgreSQL syntax):
SELECT date, platform || ' ' || usertype as "series", count(players)
FROM inapppurchase
WHERE date = ‘{{ date }}’
GROUP BY date, 2

Then use “Group By” chart option - select that concatenated value there; it will create series based on unique values from that field.

  1. Use parameter with predefined set of values and WHERE clause.

Parameter values:

'*'
'Android'
'Android', 'iOS'

In SQL:

SELECT *
FROM inapppurchase
WHERE 
  {param} = '*' -- TRUE if '*' selected - match all records
  OR platform IN ({param}) -- this will work if other value selected
  -- other WHERE statements
2 Likes

Thank you I got it working somewhat, the solution just seems unnecessary complex for something this simple. Is there a specific reason why it’s not allowed to group by multiple values in Redash by default?

At this point I’m not sure if it was some limitation of the charting library we were using or just an oversight when implementing. It’s a reasonable feature to have.

2 Likes

Yeah it feels like extremely important feature for proper analysis as I need to be able to combine different groupings flexibly while trying to look answers for specific issues or trends in the graph and this concate is really stiff for that work. I pretty much have to hard code all the combinations before starting my analysis. My measurements have on average ~10 different fields which I need to be able to combine on the fly. Hope you can do something about it soon :slight_smile:

2 Likes

We are new to redash, and we have been trying to plot time series for any number of devices in one chart.

For each deviceID, we have up to 2 time series (call them feature1 and feature2), and we would like to use a multi-value parameter {{deviceID}} available on a dashboard, so users can select multiple DeviceIDs. Therefore, each plot will have 2 x the number of selected DeviceIDs.

We used the query format above to define a seriesA as:

deviceID || ’ ’ || feature = seriesA

The workaround allows us to then group by seriesA and correctly display the 2 x number of deviceIDs series on the Y left axis.

However, feature1 and feature2 have Y values that are different by orders of magnitude, and we would like to plot all the feature1 time series on the Y left axis and all the feature2 timeseries on the Y right axis, regardless of what DeviceIDs are passed as parameter.

We see that series selected when the query is saved can be manually assigned to the left or right Y axis, but we don’t see a way to assign series to the left or right Y axis dynamically based on the value of a field (in our case, we would use the feature field to show all the feature1 values on the left Y axis and all the feature2 values on the right Y axis.)

Is there a workaround?

Thank you for your help and I hope the question is clear enough.

Best,

Valerio