Stop px-web making a sum, make average

26 views
Skip to first unread message

Beatriz Diaz Pauli

unread,
Apr 10, 2025, 7:39:48 AMApr 10
to pcaxis

Hi,


I  would like to present the average age of vessels per year, region, length group and material type. But setting ELIMINATION("region")=YES; ELIMINATION("length")=YES; ELIMINATION("material")=YES; so that the user can choose the grouping.


However, this leads to average age to be the sum per group, rather than aggregated by a new average for the new groups.  In the attached example, I would like to get the average age = 27.6, instead of the sum of all ages 138, as I get now.

 

I have AGGREGALLOWED=NO, but this only removes the "Sum values" in the results page so the user cannot make a sum. But values are still summed when not selecting from all variables in the "select variables" page.

I have also tried STOCKFA =   "A", not getting the result I want.

 

Is it possible to obtain the average value in this case?

Using PxWeb 2022 v1 and px-files.


Thank you very much for your help, 

Beatriz

example.pdf

Hans Baumgartner

unread,
Apr 10, 2025, 8:59:33 AMApr 10
to pca...@googlegroups.com

Hi,

I would recommend that all of you calculate the totals for all the classificatory variables in the table, so that there are ready calculated totals in the table. This way it does not matter if the total is an average or a %. This also uses less CPU and you can right away calculate with the total selected from the original table.

The same way we do with the variable sex

Total
Males
Females

The total is here because it can easily be calculated with.
Remember to always put the total FIRST!

The elimination key word should look like this:
ELIMINATION

- if variable is not selected it is eliminated from the table

- used vhere variables have LOGICA TOTAL

                             ELIMINATION=("Gender")="Gender total";

 

The other thing is that classificatory variables must give a logical total. So if one municipality is missing you don’t have the figures for the whole country witch is implied when eliminating the Total. The same thing with material.


Example table
https://pxweb2.stat.fi/PxWeb/pxweb/en/StatFin/StatFin__vaerak/statfin_vaerak_pxt_11re.px/

I think you get the drift …


Hans

Lähettäjä: pca...@googlegroups.com <pca...@googlegroups.com> Puolesta Beatriz Diaz Pauli
Lähetetty: torstai 10. huhtikuuta 2025 14.40
Vastaanottaja: pcaxis <pca...@googlegroups.com>
Aihe: Stop px-web making a sum, make average

--
You received this message because you are subscribed to the Google Groups "pcaxis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pcaxis+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pcaxis/ab46ce5e-dfae-4170-b304-071ec8c50dddn%40googlegroups.com.

Hans Baumgartner

unread,
Apr 11, 2025, 2:44:47 AMApr 11
to pca...@googlegroups.com

Hi,

>
so that the user can choose the grouping.


If you have % or averages in the table (other than absolute figures) you will have problems with aggregating these figures with aggregating files (groupings).
You can use agg and vs files to change the order of these values but of course you can’t aggregate (sum) them.
If you use the absolute figures in the table  you will not of course have this problem.


Hans

 

Lähettäjä: pca...@googlegroups.com <pca...@googlegroups.com> Puolesta Hans Baumgartner
Lähetetty: torstai 10. huhtikuuta 2025 15.59
Vastaanottaja: pca...@googlegroups.com
Aihe: VS: Stop px-web making a sum, make average

Beatriz Diaz Pauli

unread,
Apr 11, 2025, 3:51:06 AMApr 11
to pcaxis
Great tip, many thanks :)

Beatriz

Reply all
Reply to author
Forward
0 new messages