admin管理员组文章数量:1316680
I have a functionmacro and want to specify the name of a field in the dataset that is returned. I thought I could use #EXPAND and supply a string but when I do that I get an error saying it's an 'unknown identifier'. Here's the start of my functionmacro:
CreateDelta(CurrentDataset, PreviousDataset, ComparisonFields = '', DeltaField = 'delta_value') := FUNCTIONMACRO
InputLayout := RECORDOF(CurrentDataset);
OutputLayout := RECORD
// STRING1 delta_value;
STRING1 #EXPAND(DeltaField);
InputLayout;
END;
I would have expected the #EXPAND to make the effective ECL like the commented-out line but that doesn't happen, why not and what's the right way to do this?
I have a functionmacro and want to specify the name of a field in the dataset that is returned. I thought I could use #EXPAND and supply a string but when I do that I get an error saying it's an 'unknown identifier'. Here's the start of my functionmacro:
CreateDelta(CurrentDataset, PreviousDataset, ComparisonFields = '', DeltaField = 'delta_value') := FUNCTIONMACRO
InputLayout := RECORDOF(CurrentDataset);
OutputLayout := RECORD
// STRING1 delta_value;
STRING1 #EXPAND(DeltaField);
InputLayout;
END;
I would have expected the #EXPAND to make the effective ECL like the commented-out line but that doesn't happen, why not and what's the right way to do this?
Share Improve this question asked Jan 29 at 9:59 JCWJCW 2221 silver badge4 bronze badges1 Answer
Reset to default 0I think you are looking for #TEXT instead of #EXPAND. As in #TEXT(DeltaField).
Here is an example where I am using it:
FM_Field_Population(infile,infield,compareval) := FUNCTIONMACRO
c1 := COUNT(infile(infield=compareval));
c2 := COUNT(infile);
RETURN DATASET([{'Total Records',c2},
{'Recs=' + #TEXT(compareval),c1},
{'Population Pct',(INTEGER)((c1/c2)* 100.0)}],
{STRING15 valuetype,INTEGER val});
ENDMACRO;
GenRec := RECORD
STRING1 Gender;
END;
ds1 := DATASET([{'M'},{'M'},{'M'},{''},{''},{'M'},{''},{'M'},{'M'},{''}],GenRec);
ds2 := DATASET([{''},{'M'},{'M'},{'F'},{'F'},{'M'},{''},{''},{'M'},{''}],GenRec);
OUTPUT(FM_Field_Population(ds1,Gender,'M'));
OUTPUT(FM_Field_Population(ds2,Gender,'F'));
本文标签: hpcc eclUsing EXPAND in a record structureStack Overflow
版权声明:本文标题:hpcc ecl - Using #EXPAND in a record structure - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742005130a2411801.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论