How to create a percentage difference calculated field from an aggregate calculated field?

Hi guys,

I need to create a percentage difference calculated field from an aggregate calculated field, but it doesn’t work.

–average1
avg({limit_p}), [{id_customer}])

–average2
avg({average1})

I followed the link LAC agg function is not supported and I tried many ways, but it doesn´t work.

periodOverPeriodDifference(avgOver(avg({limit_p}), [{id_customer}]),{date_o}, MONTH, 1)

periodOverPeriodPercentDifference({media_pa_geral},{data_o}, MONTH, 1)

periodOverPeriodDifference(avgOver(avg({limite_p}),[{id_customer}]),{date_o}, MONTH, 1)

I received the error “VISUAL_CALC_REFERENCE_MISSING”

How to fix it?

Thanks,

July.

1 Like

Hello @July !

Here is a good explainer of what that error message means:

Typically when I run into that error I start trouble shooting by checking the fields that I have in my calculated field and make sure that I have them in my visual. Also, can you provide more context for your use case, why are you taking an average of an average in this case?

Hi Duncan,

I can’t put more than one field in the KPI. I added a field and it doesn’t work.

Hello @July !

With a KPI visual you are able to achieve a period over period percent difference within the visual. For example, below I have sales with a month over month difference displayed as a percent:


Above I have my Date field aggregated by month, but if I go into the field well and change this to a different period the visual will update as well.

I think what you might be running into here is that you added a dimension to your calculated field [{id_customer}] and the visual is expecting to see that in the field wells to complete the group-by. To fix this, what are you ultimately trying to see with your KPI visual? If you want to see the average of your {limit_p} field by customer id, and see all customer ids, I would recommend using a different visual. Or you could apply a parameter control to this KPI so that your reader and can filter the visual by specific customer ids.

Hi @duncan

I have a KPI visual with the current month’s value, another KPI visual with the previous month’s value.
And I have a third KPI visual that I need to make the percentage variation between the two KPI visuals, but the last KPI does not make the correct calculation.

Tks
July.

Hey @July !

I think what you are asking for is in my screenshot above. You can use one KPI visual to show the metric for this month and previous month, and have your center value be the percent difference between those two values.

The problem is when you partition by customer ID and don’t apply that into the KPI field wells the visual build will be missing elements it needs to understand the data.

2 Likes