I have a table similar to the below in Power BI.
DAX to create table:
Sample Table = {("A", 2, 3), ("B", 3, 1), ("C", 8, 12), ("D", 4, 15), ("E", , 3), ("F", 6, )}
In each column, except the first, I want to highlight the maximum and minimum values.
So Value2 would highlight 8 and 2, Value3 would highlight 15 and 1.
I've been scouring the internet trying to find something, but I'm only just learning the language so am like a Monty Python character with a foreign phrase book.
I found this which looks like it's what I'm after, but is based off of different tables and I can't figure out how to get the CurrentValue line.
MinMax =
VAR Vals =
CALCULATETABLE(
ADDCOLUMNS (
SUMMARIZE ( Sales, 'Product'[Brand], Store[Continent] ),
"@SalesAmt", [Sales Amount]
),
ALLSELECTED ()
)
VAR MinValue = MINX ( Vals, [@SalesAmt] )
VAR MaxValue = MAXX ( Vals, [@SalesAmt] )
VAR CurrentValue = [Sales Amount]
VAR Result =
SWITCH (
TRUE,
CurrentValue = MinValue, 1, -- 1 for MIN
CurrentValue = MaxValue, 2 -- 2 for MAX
)
RETURN
Result
I tried this, removing the MAXX & MINX versions as I don't think there's an expression to evaluate - I just want the MIN & MAX of that column. This caused an error though - a table of multiple values was supplied when a single value was expected.
I've tried a few variations of this, but nothing seems to be coming close yet.
Value2_MinMax =
VAR Vals = VALUES('Sample Table'[Value2])
VAR MaxValue = MAX('Sample Table'[Value2])
VAR MinValue = MIN('Sample Table'[Value2])
VAR CurrentValue = Vals
RETURN
SWITCH (
TRUE,
CurrentValue = MinValue, 1,
CurrentValue = MaxValue, 2
)
Any help would be greatly appreciated.