def transform_and_filter_result(result,camp_ids_to_filter):
    """Transforms the result of get_campaign_performance_per_period() function,
    and only includes campaign IDs that are in the list of camp_ids_to_filter"""
    final_result = list()
    for x in result[0][0]:
        if x["campaignId"] in camp_ids_to_filter:
            result_per_id = list()
            for result in x["results"]:
                result_per_id_per_day = dict()
                # The resulting dict can be modified 
                # if you need different items in it for your reporting
                result_per_id_per_day["campaign_id"] = x["campaignId"]
                result_per_id_per_day["date_from"] = result.get("metadata").get("fromDate")
                result_per_id_per_day["date_to"] = result.get("metadata").get("toDate")
                result_per_id_per_day["impressions"] = result.get("metrics").get("impressions")
                result_per_id_per_day["clicks"] = result.get("metrics").get("clicks")
                result_per_id_per_day["conversions"] = result.get("metrics").get("conversions")
                result_per_id_per_day["spend"] = result.get("metrics").get("spend")
                result_per_id.append(result_per_id_per_day)
            final_result.append(result_per_id)
    return final_result