Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi everyone!
I watched one of Albertro Ferrari's videos in which he highlights the maximum and minimum values in a matrix.
I am trying to tweek his pattern in order to highlight the maximum and minimum for each line of the matrix. Alberto’s measure, which works perfectly, goes like this:
Show Extremes =
VAR ValuesDisplayed =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( Invoices; DimSector[cdSector]; DimGroup[nmGroup] );
"@AMT"; [Fees]
);
ALLSELECTED()
)
VAR MinVal = MINX ( ValuesDisplayed; [@Amt] )
VAR MaxVal = MAXX ( ValuesDisplayed; [@Amt] )
VAR CurrentVal = [Fees]
VAR Result =
SWITCH(
TRUE();
CurrentVal = MinVal; 1;
CurrentVal = MaxVal; 2
)
RETURN
Result
I have changed this by replacing the ALLSELECTED() by another filter, specifically:
DimGroup[Group] = SelGroup
and, I added a line with
VAR SelGroup = SELECTED VALUE (DimGroup[nmGroup])
at the very beginning.
After the changes the measure is now like this:
Show Extremes =
VAR SelGroup = SELECTED VALUE (DimGroup[nmGroup])
VAR ValuesDisplayed =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( Invoices; DimSector[cdSector]; DimGroup[nmGroup] );
"@AMT"; [Fees]
);
DimGroup[Group] = SelGroup
)
VAR MinVal = MINX ( ValuesDisplayed; [@Amt] )
VAR MaxVal = MAXX ( ValuesDisplayed; [@Amt] )
VAR CurrentVal = [Fees]
VAR Result =
SWITCH(
TRUE();
CurrentVal = MinVal; 1;
CurrentVal = MaxVal; 2
)
RETURN
Result
After these changes, the first resulting table ‘ValuesDisplayed’ is correct. It returns only the lines for the selected group. I tested this using Dax Studio.
However, the MinVal and MaxVal vars seem to be seeing only the current line of ValuesDisplayed, and this results in that MinVal and MaxVal are always equal to CurrentVal.
I just can’t discover what the problem is here. Anyone can see my mistake?
Solved! Go to Solution.
@Anonymous
I downloaded Alberto's file to mess with. By changing the SUMMARIZE to look at only continet and the ALLSELECTED to do the same I was able to get the example to hightlight the MIN and MAX on each row.
MinMax =
VAR Vals =
CALCULATETABLE(
ADDCOLUMNS (
SUMMARIZE ( Sales, Store[Continent] ),
"@SalesAmt", [Sales Amount]
),
ALLSELECTED ( Store[Continent] )
)
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
SUMMARIZE ( Sales, Store[Continent], 'Product'[Brand] ) change to SUMMARIZE ( Sales, Store[Continent] )
ALLSELECTED () changed to ALLSELECTED ( Store[Continent] )
@Anonymous
I downloaded Alberto's file to mess with. By changing the SUMMARIZE to look at only continet and the ALLSELECTED to do the same I was able to get the example to hightlight the MIN and MAX on each row.
MinMax =
VAR Vals =
CALCULATETABLE(
ADDCOLUMNS (
SUMMARIZE ( Sales, Store[Continent] ),
"@SalesAmt", [Sales Amount]
),
ALLSELECTED ( Store[Continent] )
)
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
SUMMARIZE ( Sales, Store[Continent], 'Product'[Brand] ) change to SUMMARIZE ( Sales, Store[Continent] )
ALLSELECTED () changed to ALLSELECTED ( Store[Continent] )
Hi jd, what if we have multiple dimensions on rows. using the above example, we have let say Brand and Category in hierarchy on rows. so in that case how we can find the min, max value? adding on it, we want to highligh the min, max on row total as well
It worked JD, thanks!!!
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
63 | |
62 | |
52 | |
39 | |
24 |
User | Count |
---|---|
84 | |
57 | |
45 | |
42 | |
37 |