Forum Discussion

lordsriram's avatar
lordsriram
Frequent Visitor
7 years ago
Solved

SWITCH OR IF STATEMENT for PY SHIPPED AMOUNT

I am trying to get the following in a calculated measure value   When the Year is current year - I want the calculation to be     CALCULATE(SUM('TRDTA PWRBI_SALES'[SHIPPED AMOUNT]),DATESBETWEEN(...
  • Anonymous's avatar
    Anonymous
    7 years ago

    HI lordsriram,

     

    If you mean a measure contains two calculate logic based on 'today' function, you can try to use below measure formula:

    Dyanmic Measure = 
    VAR currDate =
        MAX ( Invoice[INVOICE DATE] )
    RETURN
        IF (
            YEAR ( currDate ) = YEAR ( TODAY () ),
            CALCULATE (
                SUM ( 'SALES'[SHIPPED_AMOUNT] ),
                FILTER (
                    ALLSELECTED ( Sales ),
                    [INVOICE_DATE]
                        >= DATE ( YEAR ( TODAY () ) - 1, 1, 1 )
                        && [INVOICE_DATE]
                            <= DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )
                )
            ),
            CALCULATE (
                SUM ( 'Sales'[SHIPPED_AMOUNT] ),
                FILTER (
                    ALLSELECTED ( 'Sales' ),
                    YEAR ( [INVOICE_DATE] )
                        = YEAR ( currDate ) - 1
                )
            )
        )


    Regards,
    Xiaoxin Sheng