Power BI Advanced AnalyticsLesson 47 of 53
Lesson 47 of 53

Conditional Formatting in Line Charts: Highlighting Peak (Max) & Valley (Min) Points

Overview & Learning Objectives

Unlike Bar and Column charts, Power BI Line Charts do not have a native "fx" button to color the entire continuous line conditionally. Professional BI architects solve this using a powerful DAX engineering pattern: authoring isolated Max and Min point measures, plotting them as secondary series with zero line stroke, and styling custom colored data markers (e.g. Green dot for Peak, Red dot for Valley).

  • Understand why continuous line strokes cannot be conditionally formatted natively.
  • Write DAX measures using MAXX, MINX, and ALLSELECTED to calculate peak and floor points dynamically.
  • Configure secondary marker series with stroke width = 0 to render distinct colored dots.
  • Apply dynamic conditional formatting on data labels to show exact values only at peak and valley moments.

Industry Standard

Standard: Top enterprise reporting dashboards at Bloomberg and Apple highlight peak and valley values with colored focal dots, guiding executive eyes immediately to all-time highs and operational dips.

Real-World Example: Gelato Bar Monthly Revenue Trajectory

Gelato Bar tracks monthly sales over 24 months. The CFO wants the highest revenue month highlighted with a bold Green dot and value label, and the lowest month marked with a Red dot, with all other months remaining neutral blue.

MonthTotal Sales (₹)Max Point MeasureMin Point MeasureMarker Displayed
May 2025 (Peak Summer)8,40,0008,40,000BLANK() Large Green Dot + "₹8.4L"
Jun 20257,20,000BLANK()BLANK()None (Clean line stroke)
Jan 2026 (Winter Low)2,90,000BLANK()2,90,000 Large Red Dot + "₹2.9L"
Feb 20263,50,000BLANK()BLANK()None (Clean line stroke)

Functions Covered in this Chapter

Here is the definition, exact syntax, parameter breakdown, and real-world business example for each function covered in this chapter:

Function 1

Step 1: Peak (Max) Point DAX Measure

Definition: Calculates whether the current date in the visual matches the maximum sales across the entire active filtered period. Returns the sales value if it is the peak, otherwise returns BLANK().

Syntax:
Max Sales Point = 
VAR CurrentSales = [Total Sales]
VAR MaxSalesInView = MAXX(ALLSELECTED(Dim_Calendar[Date]), [Total Sales])
RETURN
 IF(CurrentSales = MaxSalesInView, CurrentSales, BLANK())
Parameters Breakdown:
  • ALLSELECTED(Date): Scans all dates currently visible in the line chart (respecting user slicers).
  • MAXX(...): Finds the single highest sales value in that date window.
  • BLANK(): Crucial: returning BLANK() ensures no point or label is plotted for normal days.
Real-World Example (Dynamic Peak Identifier):
Problem / Scenario: If May 2025 has sales of ₹8,40,000 and all other months are lower, what does the measure return?
Formula: [Max Sales Point] evaluated for May 2025 vs June 2025
Result: May 2025 returns 8,40,000; June 2025 returns BLANK().
Why it works: Only the single highest month evaluates to TRUE and receives a numeric value.
Function 2

Step 2: Floor (Min) Point DAX Measure

Definition: Calculates whether the current date matches the minimum sales in the active filtered period. Returns the value if it is the lowest point, otherwise returns BLANK().

Syntax:
Min Sales Point = 
VAR CurrentSales = [Total Sales]
VAR MinSalesInView = MINX(ALLSELECTED(Dim_Calendar[Date]), [Total Sales])
RETURN
 IF(CurrentSales = MinSalesInView, CurrentSales, BLANK())
Parameters Breakdown:
  • MINX(...): Finds the single lowest sales value in the visible period.
  • CurrentSales = MinSalesInView: Checks equality to isolate the exact lowest trough.
Real-World Example (Dynamic Trough Identifier):
Problem / Scenario: Identify the worst performing winter month dynamically.
Formula: [Min Sales Point] evaluated for January 2026
Result: Returns 2,90,000 for Jan 2026; BLANK() for all other months.
Why it works: Isolates the single lowest point for alert styling.
Function 3

Step 3: Visual Formatting & Zero-Stroke Markers

Definition: Drop [Total Sales], [Max Sales Point], and [Min Sales Point] into the Y-axis. Set line stroke width to 0 for the Max and Min series, leaving only large distinct markers visible.

Syntax:
Format Visual -> Lines -> Series: "Max Sales Point" -> Stroke width: 0 px -> Markers: ON -> Shape: Circle -> Size: 10 -> Color: #16a34a
Parameters Breakdown:
  • Stroke Width: 0 px: Hides the line connecting the point, preventing secondary line clutter.
  • Markers -> Size & Color: Customizes the marker dot (e.g. Size 10 Green circle for Max, Red diamond for Min).
  • Data Labels -> Series Specific: Turn ON data labels ONLY for Max and Min series so numbers appear only at key moments.
Real-World Example (Executive Chart Presentation):
Problem / Scenario: What does the user see on the report canvas?
Formula: Continuous sleek blue line with one glowing Green dot at peak and one Red dot at lowest dip.
Result: Professional, uncluttered visual with immediate executive clarity.
Why it works: Because intermediate rows return BLANK(), Power BI draws zero dots for all other dates.

Common Mistakes & Limitations

  • Returning 0 instead of `BLANK()` in the IF statement (`IF(Sales=Max, Sales, 0)`); this causes Power BI to plot a dot at the very bottom (zero) for all 364 other days!
  • Using `ALL(Calendar)` instead of `ALLSELECTED(Calendar)`; `ALL` ignores user slicers, while `ALLSELECTED` correctly identifies the peak within whatever date range the user filtered.

Keyboard Shortcuts

ActionWindowsMac
Duplicate Measure for Quick EditsRight-click measure -> Copy DAXRight-click -> Copy
Format Data LabelsFormat Visual -> Data Labels -> Series SelectionData Labels menu

Pro Tips & Modern Alternatives

  • In modern Card visuals or Table/Matrix visuals, use native `fx` conditional formatting by rules.
  • Use the Color by Measure pattern (`Point Color = SWITCH(...)`) to dynamically format marker borders.