Report - IFF statement

rico1931rico1931 Member Posts: 295
edited 2012-06-21 in NAV Three Tier
Hi everyone,

Does anyone know how to write and iff statement for a report on this expression?

=Cstr(Choose(16,Split(Cstr(ReportItems!PageHeaderCaptions.Value),Chr(177))))

I've used the below code for my other reports but it seems to not work on the above..
=IIF(Code.GetData(24,3) = "CAD","CAD","USD")

can anyone give me some pointers?
-rico1931

Answers

  • azerty74azerty74 Member Posts: 82
    Can you explain what you're trying todo? Where and why are you using the expression?

    =IIF(expression, IfExpressionIsTrueThisIsTheResult,IfExpressionIsNotTrueThisIsTheResult)
    Debugging is twice as hard as writing code. Therefore if you write the code as cleverly as possible you are by definition not smart enough to debug it.
  • rico1931rico1931 Member Posts: 295
    azerty74 wrote:
    Can you explain what you're trying todo? Where and why are you using the expression?

    =IIF(expression, IfExpressionIsTrueThisIsTheResult,IfExpressionIsNotTrueThisIsTheResult)


    Hi,

    All i'm trying to do is the following : If there is no Currency code present (meaning "Blank") Show USD..

    I'm trying to do this on the Purchasing Order report where they have the following code in the header

    =Cstr(Choose(16,Split(Cstr(ReportItems!PageHeaderCaptions.Value),Chr(177))))

    This and the Purchasing quote are the only reports where I find they write the expressions like this. Every other report is much more simpler using the Code.GetData () ...all i want to do is write a simple IIF statement ](*,) :cry:
    -rico1931
  • Troubles_In_ParadiseTroubles_In_Paradise Member Posts: 588
    [quote="rico1931
    All i'm trying to do is the following : If there is no Currency code present (meaning "Blank") Show USD..

    I'm trying to do this on the Purchasing Order report where they have the following code in the header

    [/quote]
    Not sure I understood your problem but...
    You could try with something like the following:
    =IIF(Code.GetData(1,1) = "","There isn't a currency","There is a Currency")
    
    ~Rik~
    It works as expected... More or Less...
  • rico1931rico1931 Member Posts: 295
    ok let me see if I can start over.

    =Cstr(Choose(16,Split(Cstr(ReportItems!PageHeaderCaptions.Value),Chr(177))))

    Above is the expression in the text box that returns the Customer Cards Foreign Currency. What I need is a IIF statement that says something like the following

    =IIF(Cstr(Choose(16,Split(Cstr(ReportItems!PageHeaderCaptions.Value),Chr(177)))) = This part I need help on

    We have multiple currency like CAD, EUR, etc.. the above "This part I need help on" I want to put IIF =Cstr(Choose(16,Split(Cstr(ReportItems!PageHeaderCaptions.Value),Chr(177)))) = BLANK to always return USD

    that's it..

    and i've been having a complete brain fart on how to write that part..

    I hope this is better explained.. i'm sorry everyone.
    -rico1931
  • skullaskulla Member Posts: 140
    Did you try like this

    =IIF(Cstr(Choose(16,Split(Cstr(ReportItems!PageHeaderCaptions.Value),Chr(177)))) = "","USD",Cstr(Choose(16,Split(Cstr(ReportItems!PageHeaderCaptions.Value),Chr(177)))))
  • rico1931rico1931 Member Posts: 295
    Hi skulla,

    Thanks for the reply but this is actually the first thing I tried and I got a syntax error. It doesn't like Cstr(Choose(16,Split(Cstr(ReportItems!PageHeaderCaptions.Value),Chr(177)))) being used twice as an expression in the report header.
    skulla wrote:
    Did you try like this

    =IIF(Cstr(Choose(16,Split(Cstr(ReportItems!PageHeaderCaptions.Value),Chr(177)))) = "","USD",Cstr(Choose(16,Split(Cstr(ReportItems!PageHeaderCaptions.Value),Chr(177)))))
    -rico1931
  • rico1931rico1931 Member Posts: 295
    anyone have any other work around?
    -rico1931
  • rico1931rico1931 Member Posts: 295
    can anyone help me? The only option left is to redo the whole report :(:cry:
    -rico1931
  • thegunzothegunzo Member Posts: 274
    Hi Rico

    You can use the same approach as in Code.SetData and Code.GetData
    If you are already doing a SetData you can simply add this to the code in your Report.

    For example if you create a function like this (given that the currency code is in Data1):

    Public Function GetCurrencyCode as Object
    if Cstr(Choose(16, Split(Cstr(Data1),Chr(177)))) = "" then
    Return "USD"
    else
    Return Cstr(Choose(16, Split(Cstr(Data1),Chr(177))))
    end if

    Then use Code.GetCurrencyCode in your report
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
Sign In or Register to comment.