Hi,
I have a calculated field in tableau where I used Attr() function to aggregate a column in if condition like this
IF ATTR([Metric Name]) = ‘# Dedicated SSD Sites’ THEN STR(ROUND(MAX([Station Count]),0))
ELSEIF ATTR([Metric Name]) = ‘Packages Delivered’ THEN STR(ROUND(SUM([Packages Delivered])/1000000,2)) + “M”
ELSEIF ATTR([Metric Name]) = ‘% Late’ THEN STR(ROUND((SUM([Metric Num])/SUM([Metric Den])*100),2)) + “%”
ELSEIF ATTR([Metric Name]) = ‘% Late - Late Onroad’ THEN STR(ROUND((SUM([Metric Num])/SUM([Metric Den])*100),2)) + “%”
ELSEIF ATTR([Metric Name]) = ‘% Late - Late Dispatch’ THEN STR(ROUND((SUM([Metric Num])/SUM([Metric Den])*100),2)) + “%”
END
Now, I want to replicate the same field in QS. Please help me. I am unable to find the appropriate function for ATTR().
I tried this but it is throwing me "Mismatched aggregation. Custom aggregations can’t contain both aggregated and nonaggregated fields, in any combination."error:
ifelse(
{Metric Name} = ‘# Dedicated SSD Sites’,
concat(toString(round(max({metric_num}), 0)), ‘’),
{Metric Name} = ‘Packages Delivered’,
concat(toString(round({metric_num} / 1000000, 2)), ‘M’),
{Metric Name} = ‘% Late’,
concat(toString(round({metric_num} / {metric_den} * 100, 2)), ‘%’),
{Metric Name} = ‘% Late - Late Onroad’,
concat(toString(round({metric_num} / {metric_den} * 100, 2)), ‘%’),
{Metric Name} = ‘% Late - Late Dispatch’,
concat(toString(round({metric_num} / {metric_den} * 100, 2)), ‘%’),
NULL
)