Supermetrics Support Forum

How Do I Get the Count of Posts in Data Studio?

There is no default metric for getting the count of posts from Facebook, but you can generate this value with a custom calculated field in Data Studio. Here's step-by-step instructions of how to set this up!

  1. Click the edit icon for the Facebook Insights data source to bring up the field list.

    Blue arrow pointing to the pencil "edit" icon for the data source

  2. Click + ADD A FIELD to bring up the calculated field dialog.
  3. In Field Name, give the calculated field a meaningful name.
  4. In the Formula field, add the following:

    SUM(CASE WHEN Post ID IS NULL THEN 0 ELSE 1 END )


    Example of a completed field configuration:

    Example calculated column that will generate the count of posts


    You can also use COUNT(Post ID):

    Example calculated field in Data Studio to get the count of posts with "COUNT(Post ID)"

  5. Click SAVE to store the custom field.
  6. You can now add it as a "metric" type field to your report elements!

IMPORTANT!

This custom field will behave like a metric, but it's not actually a metric field request to the data source. It is still handled as a "Post ID" dimension by Facebook.


So if you use it alone without another metric, such as in a scorecard, you will get the error that "no metric is selected" as it's not legal to request the dimension without at least one metric. You can work around this in some cases with the following type of formula, which adds a true metric to the request.


Example formula to work around the "no metrics selected error, by adding and removing a true metrics: Count(PostID)+TotalImpressions-TotalImpressions

This basically adds and subtracts the metric value so that its included in the request but not actually impacting the value of the count. 


Do be aware that for some reason this does not work for all users - you may see an error that you cannot re-aggregate an already aggregated value. If that happens, you won't be able to use this workaround and will need to include the count field you created in a table or other report object that allows for metrics to be selected.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.