Right now I am working on a portal that returns median values for 3 numbers. I can only find Average, Sum, Max, and Min. The values are labeled "DataCardValue7" "DataCardValue18" and "DataCardValue1"
The formula that @rubin_boer posted is great as it'll account for a dynamic number of input values.
If you always have 3 inputs only, an alternative would be to sort the values and to retrieve item number 2, as that will return the medium.
Index(
Sort([
Value(DataCardValue1.Text),
Value(DataCardValue18.Text),
Value(DataCardValue7.Text)
]
,Value)
, 2
).Value
hi @JonRetro welcome to the community.
you have some work to do to get to the median:
Consider 3 labels txtM1, txtM2 and txtM3 with values 5, 3, 7
The average and median will be the same
Average, "Average: " & Average(txtM1.Text, txtM2.Text, txtM3.Text)
The Median is as follows, "Median" " &
With(
{
_set: [txtM1.Text,txtM2.Text,txtM3.Text] //add the number to a table or collection
},
With(
{
_n: CountRows(_set), //get the number of elements, you can hardcode it to three if thats what you will use all the time
_s: Sort(_set,Value(Value),Ascending) //sort the numbers in ascending order
},
If(
Mod(_n,2) = 0, // choose the calculation based on teh number of elements, yours can be reduced to include Index(_s,(_n+1)/2).Value only as you have an uneven number
(Index(_s,(_n/2)).Value + Index(_s,((_n + 2) / 2)).Value) / 2 ,
Index(_s,(_n+1)/2).Value
)
)
)
changing the values to show the effect
Result
Hope it helps,
R
WarrenBelz
637
Most Valuable Professional
stampcoin
570
Super User 2025 Season 2
Power Apps 1919
473