13 Replies Latest reply on Oct 12, 2018 1:13 PM by Deepak Rai

Round a float number and then display it as str in a case statement

Hi everyone,

I've seen other people answeing's about this issue, but not in a case statement. I have something like this:

CASE

WHEN 'PRECIOSKU' THEN STR(ROUND(([PrecioSku1]),1))

END

When I tried to put a Max or Min function after the Round Function, it appears without decimals. It would be easier if I use Left function, but It'd be wrong.

• 1. Re: Round a float number and then display it as str in a case statement

You need to PUT Aggregation Before ROUND

Like STR(ROUND(MAX(value),1))

• 2. Re: Round a float number and then display it as str in a case statement

HI Deepak Rai,

I've already try it, but it comes up  this message: cannot mix aggregate and non-aggregate comparisons or results in 'case' expression.

• 3. Re: Round a float number and then display it as str in a case statement

Can you attach your workbook with fake data? It can be done, it is just that your one calculation is not allowing you to do that.

• 4. Re: Round a float number and then display it as str in a case statement

Hello Ale,

I am not very clear of your requirement, but if you are asking why the precision is not coming after using the "MAX" or "MIN" function,

in that case you have to change the number format of CASE to decimal .

• 5. Re: Round a float number and then display it as str in a case statement

Here are some pics so you can understand me better

I'm working with hierarchies.

"Atr1" works with a parameter and it's a calculated field.

• 6. Re: Round a float number and then display it as str in a case statement

ATTR(Canal)

• 7. Re: Round a float number and then display it as str in a case statement

Same message

• 8. Re: Round a float number and then display it as str in a case statement

Thanks meenu choudhary, but that didn't solve the problem.

• 9. Re: Round a float number and then display it as str in a case statement

Okay,

write

ATTR(Attribute)

• 10. Re: Round a float number and then display it as str in a case statement

The same message keeps comming..

Do you have skype for business? maybe we can talk there more fluently (?)

• 11. Re: Round a float number and then display it as str in a case statement

Most Probably you have PrecioSkull as Aggregate and you are trying to Reaggregate it. by MAX..Is it so?

• 12. Re: Round a float number and then display it as str in a case statement

Yes, here it is what's inside PrecioSku1: ROUND([PrecioSku],1)

• 13. Re: Round a float number and then display it as str in a case statement

Try

STR(ROUND(MAX([PrecioSku]),1))