# Make a Bar Chart with Text Count Labels in Plot

**URL:** <https://talk.observablehq.com/t/make-a-bar-chart-with-text-count-labels-in-plot/6547>\
**Category:** Help\
**Created:** [May 13, 2022, 10:34pm UTC](https://talk.observablehq.com/t/make-a-bar-chart-with-text-count-labels-in-plot/6547 "2022-05-13T22:34:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zachbogart](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/zachbogart/32/8597_2.png) [@zachbogart](https://talk.observablehq.com/u/zachbogart)\
**Post date:** [May 13, 2022, 10:34pm UTC](https://talk.observablehq.com/t/make-a-bar-chart-with-text-count-labels-in-plot/6547/1 "2022-05-13T22:34:44Z")

</div>

**Checkout this [example notebook](https://observablehq.com/d/3b25b91638e413ef)**

_When counting up a categorical variable as a bar chart, I’d like to show the values as a text label above each bar. I can make a separate dataset using Arquero, but is it possible to access the result of a group transform from within a text mark?_

Always learning,  
Zach

---

<div class="post-metadata">

**Author:** ![mcmcclur](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mcmcclur/32/2364_2.png) [@mcmcclur](https://talk.observablehq.com/u/mcmcclur)\
**Post date:** [May 13, 2022, 11:59pm UTC](https://talk.observablehq.com/t/make-a-bar-chart-with-text-count-labels-in-plot/6547/2 "2022-05-13T23:59:31Z")

</div>

One approach is

```
      text: d => d.length, 

```

I figured this out by first trying `d => console.log(d)`

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [May 14, 2022, 1:00am UTC](https://talk.observablehq.com/t/make-a-bar-chart-with-text-count-labels-in-plot/6547/3 "2022-05-14T01:00:36Z")

</div>

Try moving the text channel declaration to the output of the group transform rather than the input. Here is a suggestion:

[https://observablehq.com/compare/3b25b91638e413ef...b71fbc332a15a928](https://observablehq.com/compare/3b25b91638e413ef...b71fbc332a15a928)
