Skip to main content
Solved

How to get max(date) from conditional attribute value

  • March 31, 2023
  • 4 replies
  • 195 views

I can't find a way to do what I want.

I got a certain number of features. I want to find the max(date) on attribute date for those features, but I want the max(date) to be in relation to a condition on a value from an another attribute status.

 

So I want the max(date) to be calculated and returned

first from feature where status = completed

if no features have a status=completed then returned max(date) from the other features

 

1 20230330 completed

2 20230329 completed

3 20230331 running

4 20230329 waiting

would returned max(date) from feature 1 : 20230330

 

1 20230330 waiting

2 20230329 running

3 20230331 running

4 20230331 waiting

would returned max(date) from feature 3 or 4 since no value set to completed :

20230331

 

 

Best answer by ebygomm

If you assign a weight to your status values, so e.g. Completed = 1, Anything Else =2 you can then sort by Status in Ascending order first, then by Date in descending order, then can use the sampler to return the first value which should return the max date from completed if it exists, but any other status if it doesn't

image

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2076 replies
  • April 2, 2023

Hi @newsafeuser​ 

 

Did you try to use the transformer StatisticCalculator?

 

Workspace_Calculator 

 

Thanks in Advance,

Danilo


  • Author
  • 4 replies
  • April 2, 2023

Hi @newsafeuser​ 

 

Did you try to use the transformer StatisticCalculator?

 

Workspace_Calculator 

 

Thanks in Advance,

Danilo

Hi,

 

Thanks for the reply, in fact if was only that I would have done just what you propose.

My problem is really handling the whole situation with the conditionnal aspect of thing, of checking first possibility and doiing calculation on it and if not check for the other possible situation to do another calculation.

 

Thanks again


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3422 replies
  • Best Answer
  • April 3, 2023

If you assign a weight to your status values, so e.g. Completed = 1, Anything Else =2 you can then sort by Status in Ascending order first, then by Date in descending order, then can use the sampler to return the first value which should return the max date from completed if it exists, but any other status if it doesn't

image


  • Author
  • 4 replies
  • April 3, 2023

Thanks a lot adding weight attribute was perfect logic for what I needed and allow to simulate all conditions.