Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

measures to find difference between current vs previous month

Hi,

Annotation 2019-11-04 142259.png

 

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

2 ACCEPTED SOLUTIONS
nandukrishnavs
Super User
Super User

Hi @Anonymous ,

 

Assuming that your source table is similar to below -

 

SourceSource

 

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

 

OutputOutput

 

 

 

 

 

 

Regards,

Nandu Krishna

 

 

 


Regards,
Nandu Krishna

View solution in original post

Anonymous
Not applicable

Thanks, @nandukrishnavs .

 

All is good. 

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

KRgds: -Nik

View solution in original post

2 REPLIES 2
nandukrishnavs
Super User
Super User

Hi @Anonymous ,

 

Assuming that your source table is similar to below -

 

SourceSource

 

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

 

OutputOutput

 

 

 

 

 

 

Regards,

Nandu Krishna

 

 

 


Regards,
Nandu Krishna

Anonymous
Not applicable

Thanks, @nandukrishnavs .

 

All is good. 

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

KRgds: -Nik

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.