Forum

This content is now out of date.

Visit Our Community

How do I concatenate Varchar & Numeric fields?

Hi,

How could I make a calculated field with combine total sales (numeric) and the Strategic_BU (text) to ?Bayu Sekamat, Total Sales: $ 189,857?

In sql :
strategic_bu + cast(sum(totalSales) as varchar(15))

But how could I do this in YF?

Thanks
Hi,

In regards to adding text the calculated field, this does depend on the database you are using.
With SQL you just need to add the text then ?+? .

Eg.

Forum image



In oracle you should use ? 'THIS'||'IS'||'A'||'TEST?

Let me know if you have any issues with this.

Regards,
David
David,

Look like YF not capable of joining text filed and a numeric field.

The ?+? not working.
We need a cast clause to convert the numeric to char than join two field.

select 'test $ ' + 1234; --This is won't work in SQL

select 'test $ ' + cast(1234 as varchar(4)); --this is a correct syntax

Hi,

It seems you actually want to append 2 columns, which should be possible via the analytic function.

Please see screenshot below:

Forum image


Though by doing this, you won't actually have a $ symbol before the value.
E.g.

Forum image


You can however use a calculated field to get around this.
1.Create the calculated field as follows:

Forum image


2.Apply the analytic function to this calculated field:

Forum image


The above methods should give you the results you were after.

You can however also use the SQL query you mentioned "select 'test $ ' + cast(1234 as varchar(4));" within a freehand calculated field, which can only be created at the view level.

Let me know how you go.

Regards,
David

Freehand sql view do not have a data security control filter.

Hi,

You can use a virtual table with your SQL query and then just join this table to to the revelant tables in your view.


Forum image


You could then apply source filters to these columns.

Regards,
David
Thanks for good answers guys, these ones were useful for me too.
By the way, if someone is interested in virtual data rooms, I've got insightful article on topic.