Power BI Exchange

Please login or click SIGN UP FOR FREE to create your PowerBIUG account to join this user group.
 View Only
  • 1.  CASE STATEMENT TO DAX

    Silver Contributor
    Posted Dec 07, 2020 03:23 PM
    Edited by Don James Dec 07, 2020 03:27 PM
    Hi All,

    I have a SQL case statement and  l want to convert to DAX to create a column.
    Below is the case statement
    ( CASE WHEN IOD.AME_WL_CD IN ('ACTIVE', 'ADD') AND IA.TYPE_ID IN ('200234') THEN 'Invoice'

    WHEN (IOD.AME_WL_CD IN ('UPGRADE') AND IOD.PRD_TYPE_DESC <> ('GITAL' )) OR IOD.AME_WL_CD IN ('SIMPARKING' , 'DONORMOBILE', 'DBO_PRD_EQP', 'DBO_PRD_SIM', 'DBO_PRD_ACC', 'DBO_PRD_SIM_PARKING') THEN 'Twkne'

    WHEN ( IOD.AME_WL_CD IN ('ACTIVE', 'ADD') AND IA.TYPE_ID <> ('567534')) OR (IOD.AME_WL_CD IN('BRE') AND IWIP.ITM_TYPE IN ('CELL' ) AND IOD.CLM_TYPE IN ( 'CON'))
    OR (IOD.AME_WL_CD IN ('PLAN', 'FEATURES', 'MOVE', 'CHANGE', 'DONEY', 'DO_NEW', 'DO_AMEND', 'DO_CANCEL', 'DO_CHANGE', 'DO_RESCHEDULE', 'DO_INST', 'DO_IN', 'DO_OUT', 'DO_SBILL', 'ENB_DO_NEW', 'ENB_DO_CANCEL', 'ENB_DO_MOD', 'ENB_DO_CHANGE'))
    OR ( IOD.AME_WL_CD IS NULL AND IOD.TYPE_DESC IN ( 'CELLESS', 'DHL', 'SHOWS', 'GITAL', 'BOXES', 'DSHOWS' ) )
    OR ( IOD.AME_WL_CD IN ('UPLOAD') AND IOD.TYPE_DESC IN ('GITAL' )) THEN 'Posmed' ELSE 'Other' END ) AS  BO_Type

    Any help is appreciated.

    Thanks
    DJ

    ------------------------------
    Don James
    77090
    Houston TX
    ------------------------------


  • 2.  RE: CASE STATEMENT TO DAX

    Gold Contributor
    Posted Dec 08, 2020 01:19 AM
    Dear Don,

    I think the Switch true approch should be able to handle it. See following link for an example:
    https://powerpivotpro.com/2015/03/the-diabolical-genius-of-switch-true/

    Best regards,
    Martin

    ------------------------------
    Martin Frisch
    BI Developer
    Trützschler GmbH & Co. KG
    ------------------------------



  • 3.  RE: CASE STATEMENT TO DAX

    Posted Dec 08, 2020 08:37 AM
    Martin, That is a very helpful function. Thanks for sharing!

    ------------------------------
    Lisa Applegate
    Senior Research Analyst
    Orono
    ------------------------------



  • 4.  RE: CASE STATEMENT TO DAX

    Posted 10 days ago
    Great help! Tx.

    ------------------------------
    Hagar Greif
    ------------------------------