Skip to main content

How to Add a Column Chart in Power Apps

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

A column chart shows totals side by side, so readers see at a glance which is bigger. Power Apps has a Column chart control: give it a table with a label column and a number column, and each row becomes a column. This guide adds one to a responsive screen, step by step.

The example is the Reports screen of the Overtime Timesheet app: one column per department, with its approved overtime hours for the month.

How the Chart Works​

From Microsoft's Column chart and Line chart reference:

  • It's three controls. Inserting a column chart adds a group of three: a Label for the title, the chart graphic, and a Legend.
  • Items is the data: a table whose first column labels the columns, and whose next columns are the numbers.
  • NumberOfSeries says how many number columns to draw. One, here.

Step 1: Make Room in a Plain Container​

Microsoft's responsive apps guide lists a known issue: the Data table, Charts, and Add Picture controls are currently not supported in the layout containers. The plain Container control isn't a layout container, and the Container reference doesn't list charts among the controls it can't hold.

So, inside the screen's vertical container, insert a Container (from Insert, search for Container; How to Add a Container Control in Power Apps). I named it conChartRS and set:

PropertyValueWhy
WidthMin(640, Parent.Width - 48)The screen's other controls' width
Align in containerStartKeeps that width
Flexible heightOff (FillPortions 0)Otherwise the container ignores its Height
Height360Room for the title, chart and legend
Drop shadowNone

A new Container started with Flexible height on, which made it ignore its Height until I turned that off.

Step 2: Insert a Column Chart​

Open Insert and search for Column chart:

The Insert pane searched for Column chart, with one result, Column chart, under Charts

Select it. Studio adds a group with sample data: cities, values, a Chart Title and an Area legend:

A sample column chart with the title Chart Title, ten columns labelled Cairo to Tokyo with values from 6 to 31, slanted labels, and a legend reading Area

The tree shows the group and its three controls, Legend1, ColumnChart1 and Title1:

The tree view with lblMessageRS and below it CompositeColumnChart1 expanded to Legend1, ColumnChart1 and Title1

I'd had the vertical container selected, so the group went into it. I cut the group in the tree view and pasted it onto conChartRS, which put it inside the plain container (How to Copy and Paste Controls Between Screens in Power Apps).

Step 3: Ungroup and Rename the Controls​

Right-click the group in the tree and select Ungroup: the container already keeps the three together. Rename them (How to Rename a Screen or Control in Power Apps):

WasNow
Title1lblChartTitleRS
ColumnChart1chtDepartmentsRS
Legend1lgdDepartmentsRS

Step 4: Give the Chart Its Data​

Set the chart's Items to a table with the label column first and the number column second. Here, one row per department with its total hours, from the screen's table of entries, locRowsRS, which has a Department and an Hours column:

chtDepartmentsRS → Items
If(
IsBlank(locRowsRS),
Blank(),
Sort(
ShowColumns(
AddColumns(GroupBy(locRowsRS, Department, Rows), Hours, Sum(Rows, Hours)),
Department,
Hours
),
Department
)
)

NumberOfSeries stays at 1. The legend's Items is chtDepartmentsRS.SeriesLabels, so it names the number column: Hours.

Step 5: Place the Three Controls​

Inside a plain container, controls are placed with X, Y, Width and Height, here from the container's size so they follow it:

ControlXYWidthHeight
lblChartTitleRS00Parent.Width32
chtDepartmentsRS040Parent.WidthParent.Height - 80
lgdDepartmentsRS0Parent.Height - 40Parent.Width40

The title's Text is "Approved hours by department", with Size 16, FontWeight FontWeight.Semibold and Align Align.Left. The three classic controls started with a different font from the app's modern controls, so I set their Font to Font.'Segoe UI'.

Step 6: Make It Readable and Accessible​

Microsoft's accessibility guidelines for charts:

  • A title right before the chart. Screen readers read controls from top to bottom, and inside a container they read the container's controls together (Organize controls in accessible canvas apps), so the title at Y 0 comes first.
  • Markers true, so each column shows its value. It was already on.
  • GridStyle GridStyle.All, so both axes show their scale. It was GridStyle.XOnly.
  • TabIndex 0 or more, so keyboard users can reach it. It was already 0.

Two more settings came from testing:

chtDepartmentsRS → AccessibleLabel
$"Approved overtime hours by department in {Text(locMonthRS, "mmmm yyyy")}"

Screen reader users get the chart's data as a table, which the reference describes and which held the full department names.

The Result​

For a payroll user in November, the chart showed both departments, from zero:

The Approved hours by department chart with a y-axis from 0 to 14, two columns of nearly equal height labelled 10 and 10.25, the labels Emergen… and Radiolo… under them, and a Hours legend

The chart shortened the department names under the columns, and nothing in its reference changes that. The app lists each full name and total under the chart (Fixed: Column Chart Cuts Off Labels with an Ellipsis in Power Apps).

Common Mistakes​

MistakeWhat happensDo this instead
Leaving the chart in a vertical or horizontal containerMicrosoft lists charts as not supported in layout containersA plain Container around the chart
Leaving Items as the sampleThe sample cities stay on the screenYour own table, label column first
Forgetting SeriesAxisMinSmall differences look large0 for amounts that can't be negative

Troubleshooting​

SymptomLikely causeFix
The container ignores its HeightFlexible height is onTurn it off
The labels end in …The chart shortens category labelsShow the full names elsewhere (fix)
Missing accessible label in the App checkerNo AccessibleLabelDescribe what the chart shows
An error about GroupBy before the data loadsGroupBy on a blank tableGuard Items with IsBlank

FAQ​

How do I chart two numbers per row?​

Add the second number column to Items after the first, set NumberOfSeries to 2, and keep the legend: the guidelines require one when more than one series is shown.

Is there a horizontal bar chart?​

Not as a separate classic control: the classic charts are the column chart, the line chart and the pie chart. Microsoft's Show data in a line, pie, or bar chart builds its bar chart with the Column chart.

Do I need the legend for one series?​

The guidelines require it only for more than one series. I kept it: it says the columns are Hours.

Conclusion​

Insert a Column chart, give its Items a table with a label column first and a number column next, and set GridStyle, Markers, SeriesAxisMin and an accessible label. On a responsive screen, put it in a plain Container inside the layout containers.

Additional Resources​