Page 1 of 1

Issue regarding aggregation function application on column

Posted: Wed May 20, 2020 12:35 pm
by VladU
Hello,

I have the following data source CSV format:
Stat1,Stat2
raw,raw
:stat1Path,:stat2Path
10,5
20,10
30,15
40,20
50,25

I'm trying to add a 2x3 table:
\ | Stat1 | Stat2 |
Max | - | - |
Avg | - | - |

If I try to write in the table field the expression I want for max/average on a particular column, it doesn't work ( {Max(testing.Stat2)} ). However, if I define a data transformation in which I compute the max/average (using basically the same formula), I can correctly display the value.

Can you please let me know if there is a method I can do this directly without defining for each column a data transformation? I am suspecting the expression I am using is not correct, but I have not found in the documentation a section that explains this part.

I have attached the .mrt file I am using.

Thank you,
Vlad

Re: Issue regarding aggregation function application on column

Posted: Thu May 21, 2020 9:06 am
by Lech Kulikowski
Hello,

You can use Totals.Max() and Totals.Avg() functions.

Thank you.

Re: Issue regarding aggregation function application on column

Posted: Fri May 22, 2020 9:16 am
by VladU
Hello Lech,

Thank you very much for the answer. The Totals.Sum part works perfectly for what I need. However, I'm still having trouble with Totals.Avg as it displays "NaN" which I assume is caused by the fact what the columns also contains non-numeric values.

Would you be kind to also help me with a method to compute the average for just the numeric values. I see that there is a function AvgIf, but I've tried multiple conditions and unfortunately none of them has worked.

Best regards,
Vlad

Re: Issue regarding aggregation function application on column

Posted: Fri May 22, 2020 9:26 am
by Lech Kulikowski
Hello,

Your column contains as string and numeric values. Please check the following expression:
{Totals.Avg(testing, (TryParseDecimal(testing.Stat1) == false ? 0 : testing.Stat1 ))}

Thank you.

Re: Issue regarding aggregation function application on column

Posted: Mon May 25, 2020 7:11 am
by VladU
Hello Lech,

This has solved my problem! Thank you very much.

Vlad

Re: Issue regarding aggregation function application on column

Posted: Mon May 25, 2020 7:52 am
by Lech Kulikowski
Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.