0

I have a table similar to the below in Power BI.

enter image description here

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
    )  

enter image description here

Any help would be greatly appreciated.

1 Answer 1

0

I've got it working, but hoping someone can improve or show a better way.
enter image description here

The DAX used to create the measure is:

MinMax2 = 
VAR Vals = CALCULATETABLE(
                            ADDCOLUMNS('Sample Table', "@Check", [Value3]),
                            ALLSELECTED()
                         )
VAR MinValue = MINX(Vals, [@Check])
VAR MaxValue = MAXX(Vals, [@Check])
VAR CurrentValue = SELECTEDVALUE('Sample Table'[Value3])
VAR Result =
    SWITCH (
        TRUE,
        CurrentValue = MinValue, 1, -- 1 for MIN
        CurrentValue = MaxValue, 2  -- 2 for MAX
    )
RETURN
   Result  

I then use it in the Conditional Formatting:

enter image description here

This does mean I need to use a different measure for each column though.
Is it possible to add parameters for the column in question, or is that a new question?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .