Forum

This content is now out of date.

Visit Our Community

Help with grouping date column

Hello,

one partner have asked me the following question:

If we have a column date:

Column
-----------
1979-11-29
1979-11-20
1986-02-03
1986-02-13
1999-10-25
1999-10-21

And now I customize in yellowfin how to see this field (view). Like this pattern: yyyy-mm

Then I can see the values like this:

1979-11
1979-11
1986-02
1986-02
1999-10
1999-10

But I can't group, how I can solve this issue?
Hi Jordi,

The best thing to do in this situation would be to some Date Hierarchy fields for the year and month at the View level, then you'll be able to group by them.

1) Go to screen 2 of the View Builder and select a Year (or Year Start Date) or Month (or Month Name) and then link it to the original timestamp field (in this example the original field is "boardingtime"):


Forum image


2) Having done that you'll be able to use them as a Report Section like this:


Forum image


Forum image


3) And also be able to group them for counting like this:

Forum image

Forum image


I hope this is what you were after, if not, or if you have any other questions then please don't hesitate to contact us.

Regards,
David
Hello!!!
My apologies but in the last email, I don't explain well. Now I have put a better example to illustrate that I want.

We suppose we have a table like this: (date of birth is a date field)

Date of Birth | Number of sons
----------------------------------------------
1979-11-29 | 3
1979-11-20 | 2
1986-02-03 | 0
1986-02-13 | 1
1999-10-25 | 2
1999-10-21 | 3

And now I customize in yellowfin (in the view section, step 2) the field Date of Birth, to see like this pattern: yyyy-mm

Now I can see the values like this:

Date of Birth | Number of sons
----------------------------------------------
1979-11 | 3
1979-11 | 2
1986-02 | 0
1986-02 | 1
1999-10 | 2
1999-10 | 3

We want to group by Date of Birth, this is the expected result:

Group Date of Birth | Sum( Number of sons)
------------------------------------------------------------------
1979-11 | 5
1986-02 | 1
1999-10 | 5


How we can achieve that?
Hi Jordi,

ahh now I understand you! My way of achieving this was to create a Freehand SQL Calculated Field at the View level with the following code:

[code]CAST( datepart(yyyy, boardingtime) AS VARCHAR(10) )+ '-' + CAST( datepart(mm, boardingtime) AS VARCHAR(10) )[/code]

I hope this time I got it right! Please let me know if that's what you were looking for.

Regards,
David