What is the replacement for Tableau's Attr() function in quicksight?

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
)

someone please #help me

Hi @snehapampari and welcome to the QuickSight community!
One quick note, when you comment on your own topic, it shows up answered and is no longer listed as a ‘new question’ which is why this may have been missed!

Are you still encountering the same issue or were you able to find a work around?
I’m not extremely familiar with Tableau in reference to what the ‘Attr()’ function does. What are you trying to accomplish with your data; what is your desired outcome?

Thank you!

Hi @snehapampari,
You could try something like the following:

ifelse(
    {Metric Name} = '# Dedicated SSD Sites',
    concat(toString(max({Station Count})), ''),
    {Metric Name} = 'Packages Delivered',
    concat(toString(round(sum({Packages Delivered}) / 1000000, 2)), 'M'),
    {Metric Name} = '% Late',
    concat(toString(round(sum({Metric Num}) / sum({Metric Den}) * 100, 2)), '%'),
    {Metric Name} = '% Late - Late Onroad',
    concat(toString(round(sum({Metric Num}) / sum({Metric Den}) * 100, 2)), '%'),
    {Metric Name} = '% Late - Late Dispatch',
    concat(toString(round(sum({Metric Num}) / sum({Metric Den}) * 100, 2)), '%'),
    NULL
)
1 Like

Hi @snehapampari,
Since we haven’t heard back, I’ll go ahead and close out this topic. However, if you have any additional questions, feel free to create a new topic in the community and link this discussion for any relevant information that may be needed.

Thank you!