Skip to main content
Solved

How to get max(date) from conditional attribute value


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

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

4 replies

danilo_fme
Evangelist
Forum|alt.badge.img+45
  • Evangelist
  • April 2, 2023

Hi @newsafeuser​ 

 

Did you try to use the transformer StatisticCalculator?

 

Workspace_Calculator 

 

Thanks in Advance,

Danilo


danilo_fme wrote:

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+38
  • Influencer
  • 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


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


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