Forum Discussion
Medmbchr
Helper IV
3 years agoReturn column name with max value (for each row)
Hi, I have a set of 4 columns with different values, and I need to put a 5th column in which I get the name of the column with the maximum value of the 4 columns (for each row). The thing is ...
- 3 years ago
You could try
Col with max value = VAR SummaryTable = UNION ( ROW ( "Column name", "Column1", "Column Value", 'Table'[Column1] ), ROW ( "Column name", "Column2", "Column Value", 'Table'[Column2] ), ROW ( "Column name", "Column3", "Column Value", 'Table'[Column3] ), ROW ( "Column name", "Column4", "Column Value", 'Table'[Column4] ) ) VAR Result = CONCATENATEX ( TOPN ( 1, SummaryTable, [Column Value] ), [Column name], ", " ) RETURN ResultIn the event of a tie it will return a comma separated list of the column names with the max value
johnt75
Super User
3 years agoYou could try
Col with max value =
VAR SummaryTable =
UNION (
ROW ( "Column name", "Column1", "Column Value", 'Table'[Column1] ),
ROW ( "Column name", "Column2", "Column Value", 'Table'[Column2] ),
ROW ( "Column name", "Column3", "Column Value", 'Table'[Column3] ),
ROW ( "Column name", "Column4", "Column Value", 'Table'[Column4] )
)
VAR Result =
CONCATENATEX ( TOPN ( 1, SummaryTable, [Column Value] ), [Column name], ", " )
RETURN
Result
In the event of a tie it will return a comma separated list of the column names with the max value
RIDWIV
Helper I
3 years agoseriously this is great, life saviour 👍