Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a table XXXX where the field YYYY has different values.
In a graphic I want to do some calculations depending on if the YYYY field contains one value or not, for example:
IF (YYYY = 'A',sum(ZZZZ)*0.115,sum(ZZZZ)*0.985)
But when I have filtered different values on YYYY field that conditional does not work.
I need one expression similar to Contains.
Thank you in advance.
sum(ZZZZ * if(YYYY='A', 0.115, 0.985))
Thanks Michael, but it didn't work because when I have all the values selected in a Filter I only want to sum a set of values with 0.985, and another set of values with 0.015 and it sums always with 0.985.
I am trying to load the calcs in a resident table using the following script
load
If(Tipo = 'YYYY' and Code = 'A1', sum(ZZZZ)) as "Value 1",
If(Tipo = 'TTTT' and Code = 'A1', sum(ZZZZ)) as "Value 2",
Resident XXXX;
But I have got the error "Invalid expression", Have I to iterate on everyrow of the XXXX table?
Thanks.
Sum() is an aggregation function which requires Group By clause in the script.
Alexis,
Tres explained why you get the error.
Still there are questions. It's not quite clear what you want. Maybe you can upload an example with explanations.
One more attempt, after re-reading your opening post, and disregarding your original expression. If "contains" is the key here, try this (not in the script but on the front end):
if(wildmatch(concat(distinct YYYY,','), '*A*'), 0.115 , 0.985) * sum(ZZZZ)
Regards,
Michael
=if(count(DISTINCT {1 <YYYY ={'A'}>} YYYY )=1, sum(ZZZZ)*0.115,sum(ZZZZ)*0.985)