Ravindra BagaleCourses & study guides मराठी Track your progress

How to Format a Column Chart in Power BI: Conditional Color with fx, Axis Range and Data Labels

A column chart of revenue by category is useful. A column chart where every category above target is green and every one below is red, with labels in the same colours, is useful at a glance. In this chapter you format the axes, set a Y-axis range the right way (full numbers, starting at 0), then reuse the idea from the card chapter: one text measure that returns a colour, plugged into the columns and the data labels through fx.

What you'll learn in this chapter

  • Clustered and stacked with two values, and when to use which
  • X-axis and Y-axis formatting; axis title
  • Y-axis Range: full numbers, minimum 0
  • A target color measure with [total revenue]
  • Columns › Color › fx › Field value
  • Data label colour with the same measure

Practice file: blinkit-sales-2023-2025.csv (1,702 order lines).

Made-up data: fictional Blinkit-style sales, for practice only. Amounts are in ₹ and dates are DD-MM-YYYY.

1. The problem

The manager's target is ₹50,000 per category over the three years. The chart should show at a glance which categories made it, with readable axes and no misleading scale.

2. The idea in simple words

Every formatting option with an fx button can take its value from a measure. A measure that returns "Green" or "Red" can colour each column, because the measure is calculated once per column, for that column's category:

target color = IF([total revenue] > 50000, "Green", "Red")

Classroom line

Wherever you see fx, you can use measures.

3. The data

Category Revenue (₹) Sales (units) Above ₹50,000?
Atta, Rice, Oil & Dals 1,01,540 383 Yes
Dairy, Bread & Eggs 55,512 770 Yes
Home, Kitchen & Pet Supplies 52,843 158 Yes
Snacks & Munchies 44,655 793 No
Fruits & Vegetables 39,107 629 No
Cold Drinks & Juices 37,186 456 No

4. Step by step

Two values, then one

  1. Clustered column chart: X-axis category, Y-axis revenue and sales. Two columns per category, side by side.
  2. Revenue (₹ thousands) and units (hundreds) do not share a scale. Remove sales from Y-axis and drag it into Tooltips instead: hover to see units.

Axes

  1. Format visual › X-axis › Values: font Segoe UI Bold, size 14, colour black.
  2. Y-axis › Range: Minimum 0, Maximum 120000. Type full numbers: 120000, not 120 for "120K".
  3. Y-axis › Title › On.

The colour measure

  1. New measure: target color = IF([total revenue] > 50000, "Green", "Red").
  2. Columns › Color › fx › Format style Field value › target color › OK. Three columns turn green, three red.

Data labels

  1. Data labels › On. Values › Color › fx › Field value › target color. The labels take the same colours.
X-axis: font 14, Segoe UI Bold, blackY-axis › Range: Minimum 0, Maximum 120000 (full numbers)Y-axis › Title: OnColumns › Color › fx › Field value › target colorData labels › Values › Color › fx › target colorIllustration (fictional data)

Figure 1. Format steps from axes to fx colours (illustration).

Classroom line

Whichever visual type you pick, the data converts to it automatically.

Classroom line

Whichever category you hover over, the sum of sales shows there too.

5. Your result should look like this

Columns coloured by target color: above ₹50,000 green, else red1,01,540Atta55,512Dairy52,843Home44,655Snacks39,107Fruits37,186Cold Drinks01,20,000Illustration (fictional data)

Figure 2. Columns above ₹50,000 in green, below in red, with labels in the same colours (illustration).

  • Green: Atta, Rice, Oil & Dals (1,01,540), Dairy, Bread & Eggs (55,512), Home, Kitchen & Pet Supplies (52,843).
  • Red: Snacks & Munchies (44,655), Fruits & Vegetables (39,107), Cold Drinks & Juices (37,186).
  • Y-axis from 0 to 1,20,000 with a title; hover shows sales.

6. What happened

  • target color is calculated once per column, in that column's filter context (its category), so each column gets its own colour.
  • The data labels use the same measure, so colours always match.
  • The Range values are raw numbers; the "K" you see on the axis is only display formatting.

Classroom line

When you need to compare two things, take a clustered column chart or a clustered bar chart.

7. Explore further

  • Keep 0 for columns. A column's height is its value; starting the axis at 30,000 makes 37,186 look tiny next to 55,512. Use a raised minimum mainly for line charts.
  • Hex colours. IF([total revenue] > 50000, "#1E8E3E", "#D93025") gives exact shades.
  • Stack only parts of a whole. Revenue split by payment can be stacked; revenue and sales together cannot.
  • Same measure, more places. The title colour, background and data labels all take fx. The card version is in How to Change Card Color and Text Dynamically in Power BI (Above or Below Target with DAX IF); the main course lesson The Format Pane covers every setting.

Classroom line

Okay, try this much.

8. Common mistakes

Wrong result Reason Fix
Range set, axis looks empty Typed 120 for 120K Type 120000
Small differences look huge Minimum above 0 Minimum 0 for columns
All columns one colour Static colour, not fx Color › fx › Field value
Measure greyed out in fx Measure returns a number Return "Green"/"Red" text
Units flattened next to ₹ Revenue and sales on one Y-axis Sales in Tooltips

Ravindra Bagale's Tip

Write the target once, in a measure such as category target = 50000, and use IF([total revenue] > [category target], …). When the target changes, you edit one number.

9. Practise on your own

Practice task

Using blinkit-sales-2023-2025.csv:

  1. Change the target to ₹45,000. How many categories are green?
  2. Make a column chart of revenue by state with target color at ₹50,000. Which states are green?
  3. What should the Y-axis maximum be for the state chart, in full numbers, to fit Maharashtra?
  4. Colour the data labels with the same measure. Which label colour does Gujarat get?
Show solution
  1. 3: Snacks & Munchies (44,655) is still just below.
  2. Maharashtra (1,22,142), Karnataka (75,009) and Telangana (52,876).
  3. Above 1,22,142, e.g. 130000.
  4. Red (₹41,446).

10. Think like a professional

  • Business view. Colour by rule turns a chart into a status board.
  • Honest axes. Bars start at 0.
  • One scale per axis. Put secondary numbers in tooltips.
  • One measure, many uses. The same target color can colour columns, labels and titles.

Interview questions

  1. How do you colour each column by a condition? Columns › Color › fx › Field value with a measure that returns a colour.
  2. Why should a column axis start at 0? Column height represents the value; a raised start exaggerates differences.
  3. What do you type in Y-axis Range for 1,20,000? 120000.
  4. How do you show revenue and sales on one column chart? They are different units: keep revenue on the Y-axis and put sales in the tooltip (or a separate visual).

Recap

In short

  1. Format X and Y axes; turn the Y title on.
  2. Range in full numbers; minimum 0 for columns.
  3. target color = IF([total revenue] > 50000, "Green", "Red").
  4. Columns › Color › fx › Field value › target color.
  5. Data labels › Color › fx › the same measure.

Ravi Sir's Cards for this lesson

मराठी cards