Menu
Stuff by Yuki
  • Home
  • Python
  • Power BI
  • Tableau
  • Community
    • Makeover Monday
    • Workout Wednesday
  • About
Stuff by Yuki

Min and Max Highlighting in Power BI

Posted on June 1, 2021July 28, 2021

WoW 2021 Week19 – Power BI

This week, I was to create a line chart whose minimum and maximum values are highlighted. I had never encountered the similar situation, but thought this is super useful! Being able to implement this in Power BI will be such a great skill to have.

DAX measures I created for this task are not as complicated as I thought they would be initially. What I simply did was:

  1. Create a measure for sum of sales
  2. Create measures of minx and maxx, keeping mind that which filter I wanted to exclude
  3. Create a measure with IF statement

Here are a few of my measures I used:

Min Val = CALCULATE( MINX( DateDim, [Sum of Sales] ), ALLSELECTED( DateDim ) )

For the measure above, you need to think about the filter context, thus I used ALLSELECTED() function. You can refer what it does to the Microsoft documentation.

Sales Min and Max = 
var minValue = [Min Val]
var maxValue = [Max Val]
RETURN
IF( minValue = [Sum of Sales] || [Max Val] = [Sum of Sales], [Sum of Sales], 
    //else
    BLANK() )

Since [Min Val] and [Max Val] are not taking into account of the filter context of Date, you can do the comparison like shown in the code.

You might’ve assumed you’d create and use only one measure for highlighting purposes, but the solution I came up with was to use 2 measures for a line chart; one showing a normal trend, the other gets turned on only when the value is minimum or maximum. There may be other ways to accomplish the same, so please let me know if you find a better way!

Data Source | Source Code

Post Views: 122

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Popular Posts

  • A Running Total Calculation with Quick Measure in Power BI
  • How To Copy And Paste Report Page in Power BI
  • How to Fill Dates Between Start Date and End Date in Power BI (Power Query)
  • How to Create an Information Panel in Power BI
  • My Experience Passing DA-100 Exam – Microsoft Certified: Data Analyst Associate

Recent Posts

  • How I Passed AWS Certified Developer Exam (DVA-C01)
  • Network Visualizations in Python – Introduction to NetworkX and Pyvis
  • DAX.do is a sandbox for DAX
  • Python Pandas .apply() function – how does it differ from .applymap() and .map()?
  • How To Copy And Paste Report Page in Power BI

connect with me

  • LinkedIn
  • Twitter
  • Github
©2022 Stuff by Yuki | Powered by SuperbThemes & WordPress