Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Problem with multiple grouping
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
szimek  
View profile  
 More options Oct 13, 6:47 am
From: szimek <szi...@gmail.com>
Date: Tue, 13 Oct 2009 03:47:34 -0700 (PDT)
Local: Tues, Oct 13 2009 6:47 am
Subject: Problem with multiple grouping
Hi,

I'm trying to create a report with user activity across the last few
months. I'd like to create a table where on X axis (table header)
there'd be month names and on Y axis (first table cell in every row)
would be user name.

Here's what I got right now: http://pastie.org/652718.
The problem is that I don't really know how to diplay all months in
the table header without creating another grouping by
['created_on_month'].

Additionally I'd like to print total activity across these months -
sum of all "subgroups.data.size" for each user i.e. in the second
column (the first column is user name).

Any tips?

Cheers,
Szymek


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew France  
View profile  
 More options Oct 13, 7:41 am
From: Andrew France <andrew+li...@avito.co.uk>
Date: Tue, 13 Oct 2009 22:41:49 +1100
Local: Tues, Oct 13 2009 7:41 am
Subject: Re: [ruport] Problem with multiple grouping
Hi Szimek,

> Here's what I got right now: http://pastie.org/652718.
> The problem is that I don't really know how to diplay all months in
> the table header without creating another grouping by
> ['created_on_month'].

Your code assumes that each user will have entries for the same months?
If that's the case, grabbing the keys from the first subgroup hash
should work?
You could also just:
@months = @table.map {|r| r['created_on_month'] }.sort.uniq

If I'm missing something you'll have to explain to me a bit further!

> Additionally I'd like to print total activity across these months -
> sum of all "subgroups.data.size" for each user i.e. in the second
> column (the first column is user name).

Not sure about the difficulty here, don't try to be super-efficient,
just iterate over the data as normal using inject(0). You could also use
the add_column method earlier on @table to calculate it.

Not sure if either of those answers help!

Regards,
Andrew


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
szimek  
View profile  
 More options Oct 13, 8:04 am
From: szimek <szi...@gmail.com>
Date: Tue, 13 Oct 2009 05:04:03 -0700 (PDT)
Local: Tues, Oct 13 2009 8:04 am
Subject: Re: Problem with multiple grouping
Thanks, this solves the problem with months and I just found out about
the problem you mentioned :)
The code assumes that each user will have entries for every month,
which is not the case, so iterating over sub groups to display the
table doesn't really work that well.

So what's the possible solution?

On Oct 13, 1:41 pm, Andrew France <andrew+li...@avito.co.uk> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
szimek  
View profile  
 More options Oct 13, 8:16 am
From: szimek <szi...@gmail.com>
Date: Tue, 13 Oct 2009 05:16:44 -0700 (PDT)
Local: Tues, Oct 13 2009 8:16 am
Subject: Re: Problem with multiple grouping
Ok, I think I got it.
Having months array I can iterate over months instead of subgroups and
select each subgroup by month. If it exists I can display its
data.size, otherwise just 0.

On Oct 13, 2:04 pm, szimek <szi...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google