Forum Discussion

ChrisMcHugh's avatar
ChrisMcHugh
Icon for Helper I rankHelper I
4 years ago

Use an IF on a column containing string value that if it returns true, returns a number

IF(AND(AND(AND(AND(VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] = "LOADED", (VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS]) <> "PARTIALLY LOADED"), (VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS]) <> "FAILED"), (VW_STAGING_TO_ACQ_LOAD_DETAIL[TABLE_NAME]) = "ROUTES"), 0)))
 
This above code will not work for me as I need a function between the last AND and VW_STAGING_TO_ACQ_DETAILS. Any function I use does not wield the correct results

9 Replies

  • Samarth_18's avatar
    Samarth_18
    Icon for Community Champion rankCommunity Champion

    Hi ChrisMcHugh ,

    If I took your question correctly then I think you could try below code:-

    IF (
        VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] = "LOADED"
            && VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] <> "PARTIALLY LOADED"
            && VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] <> "FAILED"
            && VW_STAGING_TO_ACQ_LOAD_DETAIL[TABLE_NAME] = "ROUTES",
        0
    )

     

    BR,

    Samarth

    • ChrisMcHugh's avatar
      ChrisMcHugh
      Icon for Helper I rankHelper I

      Hi Samarth,

       

      Yes it is along those lines for definite. However, upon trying your code, this is the error I am getting.

       

       

      Is there any way to work around this as I am directly pulling from a column in a dataset

      • Samarth_18's avatar
        Samarth_18
        Icon for Community Champion rankCommunity Champion

        ChrisMcHugh Please update it as:-

        IF (
            MAX ( VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] ) = "LOADED"
                && MAX ( VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] ) <> "PARTIALLY LOADED"
                && MAX ( VW_STAGING_TO_ACQ_LOAD_DETAIL[LOAD_STATUS] ) <> "FAILED"
                && MAX ( VW_STAGING_TO_ACQ_LOAD_DETAIL[TABLE_NAME] ) = "ROUTES",
            0
        )