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

Trying to get Average of Change In a Value From One Month to the Next

I have the below matrix of invoices on hold for 2 months of data so far.

 

jjanecm_1-1634570659362.png

 

 

 

I have calcualated the "Delta" as the change from previous month.  There is no data for July so the result of the calculation for August is the same as the number of invoices.

 

In the total column, somehow my Dax is counting the nubmer of invoices instead of the number of invoices last month.  For exmple the first row of the matrix the total column for Delta under the heading "Avg Number" reads "10947" which is the sum of the number of invoices for Aug and Sept(4125+6822).

 

The Dax is below.  Why is this happening and how do I get my Dax to count the number of invoices last month for each month, in the total column?

 

jjanecm_2-1634570785728.png

 

Mark Janecek

PTP Metrics Analyst 
Johsn

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous,

 

Measures are calculated based on context so in this case when you go to the total value of your measure you are not making the average but in fact you are making the calculation of the total invoices - previous month total invoices are the two months and previous is 0 becuase there are no values.

 

In this case you need to add a AVERAGEX in order to achieve what you need should be something similar to:

 

AVERAGE = IF (HASONEVALUE(Table[Monthyear]), [Delta], AVERAGEX(VALUES(Table[Monthyear]), [Delta]))

 

Be aware that depending on your model this may need some adjustments


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @Anonymous,

 

Measures are calculated based on context so in this case when you go to the total value of your measure you are not making the average but in fact you are making the calculation of the total invoices - previous month total invoices are the two months and previous is 0 becuase there are no values.

 

In this case you need to add a AVERAGEX in order to achieve what you need should be something similar to:

 

AVERAGE = IF (HASONEVALUE(Table[Monthyear]), [Delta], AVERAGEX(VALUES(Table[Monthyear]), [Delta]))

 

Be aware that depending on your model this may need some adjustments


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Thank You Miguel,  That worked great!

Hi @Anonymous 

 

Glad I could help don't forget to mark the correct answer so it can help other users.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.