cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
THanley Helper I
Helper I

Variance Minus 1 month

Hello, I'm a beginner DAX/Power Bi and am stuck as to why my logic does not work or what the correct logic should be. I'm trying to find the variance (and then percentage of variance) from month to month of a dynamic 3 month average. Bascially did the average go up or down from the previous month by how much and what percent.

 

Here is what I have so far:

Variance = CALCULATE(SUM('ARTransactiontbl'[Positive Amount]),DATESINPERIOD('Date'[Date],LASTDATE('Date'[Date]),-3,MONTH))/3
-
DATEADD(CALCULATE(SUM('ARTransactiontbl'[Positive Amount]),DATESINPERIOD('Date'[Date],LASTDATE('Date'[Date]),-3,MONTH))/3,-1,MONTH)

Pic3.JPG

4 REPLIES 4
Super User IV
Super User IV

Re: Variance Minus 1 month

See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Community Support
Community Support

Re: Variance Minus 1 month

Hi @THanley

In your formula, DATEADD is used uncorrectly.  please read reference here to learn the usage.

Variance = CALCULATE(SUM('ARTransactiontbl'[Positive Amount]),DATESINPERIOD('Date'[Date],LASTDATE('Date'[Date]),-3,MONTH))/3
-
DATEADD(CALCULATE(SUM('ARTransactiontbl'[Positive Amount]),DATESINPERIOD('Date'[Date],LASTDATE('Date'[Date]),-3,MONTH))/3,-1,MONTH)

Based on my understanding, 

"a dynamic 3 month average" means, eg, 

for 2018/10, avg=(2018/8+2018/9+2018/10)/3

for 2018/11, avg=(2018/9+2018/10+2018/11)/3

for 2018/12, avg=(2018/10+2018/11+2018/12)/3

 

then the percentage of variance should be 

for 2018/10, (avg-2018/9)/2018/9

for 2018/11, (avg-2018/10)/2018/10

for 2018/12, (avg-2018/10)/2018/10

 

Is my understanding right?

 

Best Regards

Maggie

 

 

 

THanley Helper I
Helper I

Re: Variance Minus 1 month

Hi Maggie,

 

I though my use was correct. Your reference says: DATEADD(<dates>,<number_of_intervals>,<interval>)

 

My assupmtion: 

<dates>: (CALCULATE(SUM('ARTransactiontbl'[Positive Amount]),DATESINPERIOD('Date'[Date],LASTDATE('Date'[Date]),-3,MONTH))/3

 

<number_of_intervals>: -1

 

<interval>: MONTH

 

Is my assumption incorrect because I have the Calculated Sum as part of the <date>?

 

Sincerely,

Tom

THanley Helper I
Helper I

Re: Variance Minus 1 month

Hi Maggie,

 

I forgot to respond to your understanding - You are absolutely correct in your math.

 

Tom

Helpful resources

Announcements
Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

‘Better Together’ Integration Forum Launch

‘Better Together’ Integration Forum Launch

We've launched a how-to forum where you can learn about how Power BI integrates with other Power Platform products.

Top Solution Authors
Top Kudoed Authors