Skip to main content
Solved

Group features by week number


Forum|alt.badge.img

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.

Best answer by david_r

manca_ent wrote:

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"

View original
Did this help you find an answer to your question?

11 replies

david_r
Celebrity
  • October 7, 2022

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

image


Forum|alt.badge.img
  • Author
  • October 7, 2022
david_r wrote:

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.


david_r
Celebrity
  • October 7, 2022
manca_ent wrote:

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?


Forum|alt.badge.img
  • Author
  • October 7, 2022
manca_ent wrote:

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.


david_r
Celebrity
  • October 7, 2022
manca_ent wrote:

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 


Forum|alt.badge.img
  • Author
  • October 7, 2022
manca_ent wrote:

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.


david_r
Celebrity
  • Best Answer
  • October 7, 2022
manca_ent wrote:

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"


Forum|alt.badge.img
  • Author
  • October 7, 2022
manca_ent wrote:

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.


david_r
Celebrity
  • October 7, 2022
manca_ent wrote:

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.


Forum|alt.badge.img
  • Author
  • October 7, 2022
manca_ent wrote:

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 :)


david_r
Celebrity
  • October 7, 2022
manca_ent wrote:

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 ;-)


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings