# Percent for last month of data

Hello,
I have a % calculation that works correctly at month level but I need to add a KPI object that shows me the value of the last month of data. How can I do it?

Thank you very much

Hi @CarlosM ,

Using the lag function in a calculated field can be used to help with that.

Something like:

lag(sum(value-field),[date-field ASC],1)

Hope that helps.

My problem is in the summary because it does the calculation at aggregation level and i need the value from the last month.
In the example right value is the month 12, in this case -4,21%

Are you saying you just want -4.21 % across all?

Can you do something like this?

sumOver(
sum(ifelse(Month=12,{3c},0))
)

@CarlosM

can you give us more details about what exactly you are trying to do?
Last month data for each row/month? Last month data (from today’s date)? Can you include a snapshot with more details?

Thanks,
GL

Hi,
i’m trying to show the last month’s target percent for each commercial in a KPI object. in each case it will be in a different month depending on their target.
I can get the value in a calculated column (thanks @Max for the calculation) but when i try to show in the kpi object i get an unexpected result again.

Check your settings for the KPI chart. There are a number of options. Looks like you’re showing a sum of 3c right now- what do you have in the field wells?

I haven’t that option in a kpi object

Hello @CarlosM , After going through the thread whatever I could understand, I tried to replicate it at my end with one of my own sample dataset. Please find the below snapshot where I have outlined what I have tried. Let me know if this helps. Cheers!

@CarlosM
Two things:

1. to see the options @todd.hoffman is referring to, you need to have a date in the Trend group.

Example:

1. What is your calculation for “last month’s target percent”? Can you add the date you are using in that calculation to the Trend Group?

GL