def _build_keys(self, static_groups_of_interest, dynamic_groups_of_interest, static_grouping_key,
                    dynamic_grouping_key):
        static_key = self._get_static_key(static_groups_of_interest, static_grouping_key)
        dynamic_keys = self._get_dynamic_keys(dynamic_groups_of_interest, dynamic_grouping_key)

        keys = []

        if static_grouping_key == "groupingsAcross":
            for el in dynamic_keys["keys"]:
                key = "{}!{}".format(el, static_key)
                keys.append(key)
        else:
            for el in dynamic_keys["keys"]:
                key = "{}!{}".format(static_key, el)
                keys.append(key)

        return {"keys": keys, "labels": dynamic_keys["labels"]}