Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi.
I have the following table and I need to calculate the last "Peso" - the first "Peso" of each IdAnimal in a KPI. This has to be dynamic. In the first example I have selected the years 2021 and 2022 and in the second example I only have the year 2021 selected.
Regards.
Try changing this property to sum -
OR expression to as below -
sum(Aggr(FirstSortedValue(Peso,-FechaEvPS)-FirstSortedValue(Peso,FechaEvPS),IdAnimal))
@spividori Please look at the Script used in the back end. Have a look at it and let me know if this something that you are looking for:
NoConcatenate
Temp:
Load IdAnimal,
Date(Date#(Date,'DD/MM/YYYY'),'MM/DD/YYYY') as Date,
Peso
Inline [
IdAnimal, Date, Peso
30695,13/05/2021,500
30695,19/08/2021,259
30695,22/09/2021,370
30695,03/12/2021,346
30695,02/08/2022,414
30772,21/01/2021,314
30772,15/04/2021,403
30772,29/06/2021,436
30772,19/08/2021,432
30772,15/10/2021,465
30772,25/11/2021,469
];
NoConcatenate
Temp1:
Load IdAnimal,
FirstSortedValue(Peso,Date) as FirstValue,
FirstSortedValue(Peso,-Date) as lastValue
Resident Temp
group by IdAnimal;
NoConcatenate
Temp2:
Load IdAnimal,
FirstValue,
lastValue,
lastValue-FirstValue as Difference
Resident Temp1;
Drop table Temp,Temp1;
Exit Script;
May be in the front-end like this -
Thanks for answering.
The total by IdAnimal is correct but I need the general total to be the sum of the result of each IdAnimal. in the example of the image it should be: 69, not 100.
Try changing this property to sum -
OR expression to as below -
sum(Aggr(FirstSortedValue(Peso,-FechaEvPS)-FirstSortedValue(Peso,FechaEvPS),IdAnimal))
Hi.
Yes. It's what I needed. Thank you very much!.
Regards.