Solved

Group features by week number


Badge

My dataset contains date attributes per day that work was completed. My output needs to have the count of attributes that fall within any given week - example week 40 has 25 attributes - going back to the start of the year. I'm new to working with dates in FME so any help would be appreciated.

icon

Best answer by david_r 7 October 2022, 17:40

View original

11 replies

Userlevel 4

You can use the DateTimeConverter with either of these output formats, then use the result in the Group By in the following transformers:

image

Badge

You can use the DateTimeConverter with either of these output formats, then use the result in the Group By in the following transformers:

image

Thank you for the reply. The first roadblock I'm hitting is within the DateTimeConverter. The output attribute values are the exact same as they came in no matter which output format I use.

Userlevel 4

Thank you for the reply. The first roadblock I'm hitting is within the DateTimeConverter. The output attribute values are the exact same as they came in no matter which output format I use.

Can you post a screenshot of your DateTimeConverter, as well as post a sample input attribute value?

Badge

Thank you for the reply. The first roadblock I'm hitting is within the DateTimeConverter. The output attribute values are the exact same as they came in no matter which output format I use.

SnapshotThe output always looks the same as the input shown here.

Userlevel 4

Thank you for the reply. The first roadblock I'm hitting is within the DateTimeConverter. The output attribute values are the exact same as they came in no matter which output format I use.

Weird, it works for me:imageHowever, I'm wondering if you're looking at the right data. Based on the visual preview table name, you're looking at the output from the Reader, not from the DateTimeConverter:

image 

Badge

Thank you for the reply. The first roadblock I'm hitting is within the DateTimeConverter. The output attribute values are the exact same as they came in no matter which output format I use.

Very weird. I opened the Reader data in the screenshot just to show you how the input looks.

Userlevel 4

Thank you for the reply. The first roadblock I'm hitting is within the DateTimeConverter. The output attribute values are the exact same as they came in no matter which output format I use.

It seems you wrote "@Value(EditDate_2)" in the input attribute of the DateTimeConverter. You should only have "EditDate_2" there, as in my screenshot above. Otherwise you're referring to a different attribute, named after the actual datetime value, e.g. an attribute named "20220422124317.10"

Badge

Thank you for the reply. The first roadblock I'm hitting is within the DateTimeConverter. The output attribute values are the exact same as they came in no matter which output format I use.

Yes! This was it, I can't believe I missed that. Thank you, it's outputting as expected now.

 

Could you by chance also post the transformers you suggested I use above? I cannot see them attached to your reply.

Userlevel 4

Thank you for the reply. The first roadblock I'm hitting is within the DateTimeConverter. The output attribute values are the exact same as they came in no matter which output format I use.

I didn't make any suggestions for further transformers, as it's not completely clear to me what you're trying to accomplish. But maybe look into the Aggregator and/or the StatisticsCalculator, they both make it possible to aggregate the data based on the results from the DateTimeConverter. Or consider posting it as a separate question.

Badge

Thank you for the reply. The first roadblock I'm hitting is within the DateTimeConverter. The output attribute values are the exact same as they came in no matter which output format I use.

Thanks for your help David, much appreciated :)

Userlevel 4

Thank you for the reply. The first roadblock I'm hitting is within the DateTimeConverter. The output attribute values are the exact same as they came in no matter which output format I use.

You're welcome! And feel free to give an upvote and "select as best" if you want to ;-)

Reply