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

Find Min Value from entire table

Hello,

if i have a simple table , for example like the one below with 3 columns (A,B,C) and 3 rows:

A   |   B |  C

1   |  7   |  9

2   | 11  | 13

5   | 21  |  3

How do i find a field with lowest value from the entire table ? i know how to use MIN with Group BY but that would give me only a MIN value per column and i am looking for the minimum value of the entire table. so in ,y example that would be 1 (column A in first row) 

Thanks in advance,

Vladimir

 

1 Solution

Accepted Solutions
javiersassen
Partner - Contributor III
Partner - Contributor III

So first you create a variable, either in your script or in the edit sheets view (can only be done in unpublished dashboards)

SET vMinA = Min(A);

and then to user it in for instance a measure you have to evaluate the variable using $()

$(vMinA)

 

View solution in original post

8 Replies
Wlad_Masi
Employee
Employee

Hi @vladimirkup ,

 

I would probably use the min function in each column, store in variables and compere them.
I am afraid we won't have a way to pick the lowest number of the table as one.

To help users find verified answers, please don't forget to mark a correct resolution or answer to your problem or question as correct.
javiersassen
Partner - Contributor III
Partner - Contributor III

First question would be why do you want/need it? Second, does it have to be dynamic or is a static value fine?

vladimirkup
Contributor III
Contributor III
Author

it's an intermediate calculation that will be used later. it's an dynamic value, the whole table will be updated on a daily basis. 

vladimirkup
Contributor III
Contributor III
Author

Hi,

Can you show please how to store min function from each column in a variable  ? can you provide code example fro that ? 

Thanks in advance

javiersassen
Partner - Contributor III
Partner - Contributor III

I might have a better solution:

OriginalTable:
LOAD * INLINE [
RowId, 	A, 	B, 	C
1, 		1, 	7, 	9
2, 		2, 	11,	13
3, 		5, 	21, 3];

MinValue:
CrossTable(Column,Value)
Load * resident OriginalTable;

 

In this way you have your original table, based on selections in your original table your min value changes. Your function to calculate the min value in the table would now be Min(Value).

 

Let me know if this helped!

vladimirkup
Contributor III
Contributor III
Author

Wow, great idea, nice and easy, really helped me with that. 

Just before i close this case  can you show please how to store min function from each column in a variable ?  That was your initial idea.

I will very appreciate that.

 

javiersassen
Partner - Contributor III
Partner - Contributor III

So first you create a variable, either in your script or in the edit sheets view (can only be done in unpublished dashboards)

SET vMinA = Min(A);

and then to user it in for instance a measure you have to evaluate the variable using $()

$(vMinA)

 

vladimirkup
Contributor III
Contributor III
Author

Thanks !