malloy icon indicating copy to clipboard operation
malloy copied to clipboard

Pivots that are all measures need to show the pivot name.

Open lloydtabb opened this issue 1 year ago • 0 comments

In the first query, we dont' see the column names for the pivots and we should. The unique thing here is that the pivots are all measures so it really isn't quite a pivot...

image

source: airports is duckdb.table('../data/airports.parquet') extend {

  measure: 
    airport_count is count()
    average_elevation is elevation.avg()

  view:
    metrics is {aggregate: airport_count, average_elevation}
}

run: airports ->
  {group_by: fac_type} + metrics
  + {
    # pivot
    nest:
      ny is metrics + {where: state='NY'}
      ca is metrics + {where: state='CA'}
  }


run: airports ->
  {group_by: fac_type} + metrics
  + {
    # pivot
    nest:
      by_state is {
        where: state = 'CA' | 'NY'
        group_by: state
      } +  metrics
  }

lloydtabb avatar Oct 31 '23 12:10 lloydtabb