1 Reply Latest reply on Oct 15, 2018 4:00 AM by Mahfooj Khan

# Switch dimension based on count in a field

Hi all,

I have a field with a lot of products. If no products are selected I want to show my Year dimension (eg 2016, 2017, 2018) if a product is selected I want to show a combination of the year and a serie number (eg 2016-12, 2017-13, 2018-14). This second field is a calculated dimensions from 2 field which looks like this: Year +"-"+ int([Serie number]).

Now I have created a formula which looks like: If CountD([Serie number]) = 1 THEN CombinationField ELSE Year END

The problem I have that it either gives me a combination of int and string error which I have solved by making the serie number a int field.

But now I have the problem that it tells me I can't mix aggr and non aggr fields because the Year/Serie combination is apparently seen as an aggregation.

Looking for some help how to fix this, I doesn't sound to me like a very difficult question but I can't get it to work.

Best regards,

Paul

• ###### 1. Re: Switch dimension based on count in a field

Hi,

I don't know how much I've understood your question, seeing your logic I found you need to use ATTR() outside of your Combined field and Year.

If CountD([Serie number]) = 1 THEN ATTR(CombinationField) ELSE ATTR(Year) END

Mahfooj