Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
When and where to use RangeMin() and RangeMax() function?
You can use these functions in chart expressions or script. While writing chart expressions or script.
Why not just have a look at the HELP?
Is usefull when you want to keep the max of two different fields:
Date(RangeMax([Original Due Date], [Negotiated Due Date]))
Or if you want to set a min or max value to an expression (in example for dynamic axis range):
RangeMin(Sum(Profit), -1) // The axis will start at -1 even if all profits are positive, if there are a more negative number, it will take the lower.
Wherever you would specify all values as a comma-separated list.
Just for the fun of it, let's introduce a visual analogy: vertical and horizontal value specifications.
Note that you can also use fieldnames in a RangeMax() parameter list, but they will only produce sensible results if they refer to a single value at a time. Like in:
Sum(RangeMax(Total1, Total2, Total2))
where Total1, Total2 and Total3 are all from a single row or from a single set of connected rows in different tables. Otherwise every Total value will return NULL because RangeMax expects a single value for every parameter.
Best,
Peter
[Edit] Sorry, (Range)Max picks the largest values, not the smallest.
Hi, Thanks for prompt response.
Actually, I have come across below script and couldn't able to understand the functionality of RangeMin() and RangeMax()
TempSubIntervals:
LOAD Distinct
StartDate as [ES Start Date],
EndDate as [ES END Date],
IntervalId
Resident RoomDetail;
SubIntervals:
LOAD *, SubFromDate &'|'& SubToDate as SubIntervalID;
LOAD
IntervalId,
date(RangeMax([ES Start Date])) as SubFromDate,
date(RangeMin([ES END Date])) as SubToDate
Resident TempSubIntervals;
If you are using RangeMin() / RangeMax() with a single argument, there is no real benefit from using these functions at all (
since the HELP says for RangeMax():
"Returns the highest numeric values found within a range of 1 to N arguments. If no numeric value is found, NULL is returned.")
Hence, if there is only one numeric value in the range, it will return just this value.
Hi, in that particular case, I don't understand either, I think that's similar to:
SubIntervals:
LOAD *, SubFromDate &'|'& SubToDate as SubIntervalID;
LOAD
IntervalId,
date([ES Start Date]) as SubFromDate,
date([ES END Date]) as SubToDate
Resident TempSubIntervals;
Maybe is trying:
LOAD *, SubFromDate &'|'& SubToDate as SubIntervalID;
LOAD
IntervalId,
date(Max([ES Start Date])) as SubFromDate,
date(Min([ES END Date])) as SubToDate
Resident TempSubIntervals
Group by IntervalId;
Hi,
rangemin(expr1 [ , expr2, ... exprN ])
Returns the lowest numeric value found within a range 1 to N arguments. If no numeric value is found, NULL is returned.
Examples:
rangemin (1,2,4) | returns 1 |
rangemin (1,'xyz') | returns 1 |
rangemin (null( ), 'abc') | returns NULL |
rangemin (above(sum(x),-1,3)) | returns the lowest of the three results of the sum(x) function evaluated on the row below the current row, the current row and the row above the current row. |
rangemax(expr1 [ , expr2, ... exprN ])
Returns the highest numeric values found within a range of 1 to N arguments. If no numeric value is found, NULL is returned.
Examples:
rangemax (1,2,4) | returns 4 |
rangemax (1,'xyz') | returns 1 |
rangemax (null( ), 'abc') | returns NULL |
rangemax (above(sum(x),-1,3)) | returns the highest of the three results of the sum(x) function evaluated on the row below the current row, the current row and the row above the current row. |
So to summarize the previous, the use of RangeXXX() functions in this particular case will translate all non-numeric values to NULL and will leave the numeric values alone.
Ruben clearly shows in hist first example that there are shorter ways to do the same, so the original may not be a code sample worth spending your time on...
Peter