Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

measures to find difference between current vs previous month

Hi,

 

To calc the variance between current vs previous month amounts, I use this formula:

    AdsPromo Var = if([AdsPromo LM] = BLANK(), 0, 
          [AdsPromo]-[AdsPromo LM])

 

For Feb17, the AdsPromo Var amount is still 0 using the above formula when it should be 464 (464-0). Kindly advise on how resolve the error in the measure/DAX.


Tks: -Nik

  • Hi Anonymous ,

     

    Assuming that your source table is similar to below -

     

    Source

     

    If you are looking for a measure, use below DAX query - 

     

     

    AdsPromo Var =
    VAR current_Month =
        CALCULATE ( SUM ( 'Table'[AdsPromo] ) )
    VAR previous_Month =
        CALCULATE ( SUM ( 'Table'[AdsPromo] ), PREVIOUSMONTH ( 'Table'[Month-S] ) )
    VAR AdsPromoVariance = current_Month - previous_Month
    RETURN
        AdsPromoVariance

     

     

    The Month-S column should be the date type. 

     

    Here is the output

     

    Output

     

     

     

     

     

     

    Regards,

    Nandu Krishna

     

     

     

  • Anonymous's avatar
    Anonymous
    6 years ago

    Thanks, nandukrishnavs .

     

    All is good. 

    In fact, I have also managed to create the variance percentage subsequently.

    KRgds: -Nik

2 Replies

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

    Hi Anonymous ,

     

    Assuming that your source table is similar to below -

     

    Source

     

    If you are looking for a measure, use below DAX query - 

     

     

    AdsPromo Var =
    VAR current_Month =
        CALCULATE ( SUM ( 'Table'[AdsPromo] ) )
    VAR previous_Month =
        CALCULATE ( SUM ( 'Table'[AdsPromo] ), PREVIOUSMONTH ( 'Table'[Month-S] ) )
    VAR AdsPromoVariance = current_Month - previous_Month
    RETURN
        AdsPromoVariance

     

     

    The Month-S column should be the date type. 

     

    Here is the output

     

    Output

     

     

     

     

     

     

    Regards,

    Nandu Krishna

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks, nandukrishnavs .

       

      All is good. 

      In fact, I have also managed to create the variance percentage subsequently.

      KRgds: -Nik