dynamic currency symbol

david berlinger 96 Reputation points
2020-10-16T05:41:10.59+00:00

in ssrs, i want to define the currency symbased based on a code in the dataset.
ie sometimes the amount is dollar, euro, etc. a flag would indicate which currency symbol to use.
any idea how to implement this?

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
3,064 questions
0 comments No comments
{count} votes

Accepted answer
  1. david berlinger 96 Reputation points
    2020-10-22T05:34:26.88+00:00

    i finally gave up using the custom format of the textbox, and reset it to general with no formatting. in the expression I manipulated the data to be:
    fields!symbol.value & formatnumber(fields!cost.value,0)
    and is is displaying correctly

    0 comments No comments

7 additional answers

Sort by: Most helpful
  1. ZoeHui-MSFT 41,491 Reputation points
    2020-10-20T05:34:26.873+00:00

    Hi @david berlinger ,

    It would be great if you could provide a minimal reproducible example:

    (1) DDL and sample data population, i.e. CREATE table(s) plus INSERT, T-SQL statements.

    (2) What you need to do, i.e. logic.

    (3) Desired output based on the sample data in #1 above.

    Regards,

    Zoe

    0 comments No comments

  2. david berlinger 96 Reputation points
    2020-10-20T06:27:03.603+00:00

    create table ref (key tinyint identity(1,1),desc varchar(20), symbol nchar(3),exchange_rate decimal(9.2))
    insert into ref (desc,symbol)
    values ('dollar','$',0.33).('euro','€', 0.5),('nis','₪',1.00)

    create table data(item varchar(50),cost money,currency tinyint)
    insert into data(item,cost,currency)
    values ('hotel',1046.78,1),('plane fare',862.21,2),('car rental',2450.00,2),
    ('lecturer',10,900,3),('discount',-100,1)

    i want in SSRS to display the cost with the appropriate currency sigh and formatted with commas (1,046 rather than 1046), negative numbers in red and a specified format

    the cost column should be able to be totaled with the appropriate monetary symbol as I want a parameter "currency display "to allow the user to chose the currency to be displayed (from table ref). I would write code to convert all currencies to the chosen currency.
    the quest is how to format the text box to change the currency symbol based on the parameter chosen or the data in the "data" table

    0 comments No comments

  3. ZoeHui-MSFT 41,491 Reputation points
    2020-10-21T08:50:11.013+00:00

    Hi @david berlinger ,

    With the data you provided, I did some local test. Hope it could give you some ideas.

    1.Add the dataset to the report with you query.

    select *, cost/exchange_rate as newcost  from data  
    inner join ref  
    on ref.[key]=data.currency  
    

    2.Set the property of the text box with currency-custom.
    34031-screenshot-2020-10-21-163322.jpg
    3.Set the color font of the text with

    =IIF(InStr(Fields!newcost.Value,"-"),"red","Black")  
    

    The report will be shown like this:
    33993-screenshot-2020-10-21-163632.jpg

    If I misunderstand your meaning, please incorrect me.

    Regards,

    Zoe


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.