Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
nikonmike
Contributor III
Contributor III

Find minimum

I need to find the minimum factor across a set time frame (which could change based on selections).  This min factor would then be used to adjust the Amount based on the current Factor.  The first step however, is to be able to calculate the min factor.

In the example below, I used RangeMin(Factor) for the Min Factor column.  As you can see, it's changing with each period but what I really need is for the result to be the Factor for the earliest Period, which is 2.7738.

Factor.PNG

8 Replies
ogautier62
Specialist II
Specialist II

Hi,

could you put exactly the expected result please ?

if you mean the min factor for location : min(total <Location> Factor)

or is it min for location and prior period ? :

    rangemin(above(Factor))

regards

undergrinder
Specialist II
Specialist II

Hi Mike,

do you want it on the frontend editor or in load script?

in load script try this (min for location):

Load

     Location,

     Min(Factor) as minFactor

From/Resident [table]

Group by Location;

If you want to add to the final table the whole script looks like this:


final:

Load * from/resident [table];


left join(final)

Load

     Location,

     Min(Factor) as minFactor

From/Resident

Group by Location;

G.




nikonmike
Contributor III
Contributor III
Author

In the example above, the Min. Factor should be 2.7738 for all rows since it was the Factor for the earliest Period in the table.

The formula you listed above, "min(total <Location> Factor)", gave a result of 2.7728 which is the lowest of all the Factors in the table. That's close and would be very helpful when I need to expand this calculation to include multiple locations.

nikonmike
Contributor III
Contributor III
Author

I don't think it can be in the Load script since the Period can change based on selections and therefore the Min Factor would need to change.

ogautier62
Specialist II
Specialist II

so

min(total Factor) for all locations !

nikonmike
Contributor III
Contributor III
Author

That gives me the 2.7728 number, which is the min Factor, but not the factor for the min Period, which is 2.7738. 

nikonmike
Contributor III
Contributor III
Author

Think I got it to work with this formula:

FirstSortedValue(total <Location> Factor, Period)

ogautier62
Specialist II
Specialist II

ah ok

so :

FirstSortedValue(Factor,- Period)  if it suits dimensions

or

FirstSortedValue(Factor,- aggr(only(Period), the dimensions you want))