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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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