How to Format a Summary of a Table for posting to Slack

Hi folks!

I’m playing around with posting a summary of data from a table into a Slack message.

Let’s say I have a table like this:

| foo | 1 |
| foo | 2 |
| bar | 5 |
| baz | 2 |
| foo | 1 |

What I’d like to do is post a summary of that table to a Slack message such that I’d have a message like:

Summary:

  • Foo = 4
  • Bar = 5
  • Baz = 2

That is, the sum of the second column, per grouping of the first column.

This is how I display the data on one of my pages, using a normal table, grouped by the first column, collapsed with a Sum summarization at the bottom of the second column.

I think I have a handle on how to set the Format() template to output the information that I want, but I can’t seem to figure out what I’m missing to have it loop over the groups and put out a bullet per group.

Is there an example of this somewhere, or maybe I’m approaching this wrong?

Thanks in advance!

Hi @Thomas_Robbs1 ,

Maybe this could help:

[My Table].Name.Unique().
  FormulaMap(CurrentValue.WithName(name, 
    Format("{1}: {2}", 
      name, 
      [My Table].Filter(Name=name).Value.Sum()
      )
    )
  ).BulletedList()

A simplified version, without WithName(), here unnecessary, even though I tend to use it anyway:

[My Table].Name.Unique().
  FormulaMap(
    Format("{1}: {2}", 
      CurrentValue, 
      [My Table].Filter(Name=CurrentValue).Value.Sum()
    )
  ).BulletedList()

Let me know if you have further questions.
Cheers!

3 Likes

Thank you @Federico_Stefanato ! This is exactly what I needed.

1 Like