We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

get avg in row excluding zero or null value

Answered
Luana Piroli asked on February 24, 2023

Good morning,
I have to create a measures that is:
avg of Vitalita when Vitalita <> null (i can change null value in 0)
for example my DataSet

{
        "Anno Congelamento": null,
        "Mese Congelamento": "00 ",
        "Trimestre Congelamento": null,
        "Vitalita": null,
        "cd34 buffy": null,
        "Kit": 0
    },
    {
        "Anno Congelamento": "2016",
        "Mese Congelamento": "06 giugno",
        "Trimestre Congelamento": "apr-giu",
        "Vitalita": "96.04",
        "cd34 buffy": "627750",
        "Kit": 27
    },
    {
        "Anno Congelamento": "2016",
        "Mese Congelamento": "07 luglio",
        "Trimestre Congelamento": "lug-set",
        "Vitalita": "98.66",
        "cd34 buffy": "2347200",
        "Kit": 28
    }

For example for rows

"Anno Congelamento"

 
 

2 answers

Public
Luana Piroli February 24, 2023

excuse me,
I can't exclude rows because I've to count the Kit value

Public
Maksym Diachenko Maksym Diachenko Flexmonster February 24, 2023

Hello, Launa!

Thank  you for reaching out to us.

It is possible to create this measure using the calculated values feature. Knowing that the average queals to a sum divided by count, we can use the default sum aggregation since it is not affected by zero values and divide it on amount of non-zero "Vitalita" values. You are welcome to check the example: https://jsfiddle.net/flexmonster/k5g3eq4w/ 

Please let us know if this would work for you.

Best Regards,
Maksym 

Please login or Register to Submit Answer