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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

sum of deviation in relation to previous month

 

Hi everyone

I have a problem and I can not solve it.
I have a table like this:

Rick_ferreira_0-1622452637683.png

I need to build a graph with a sum of deviation in relation to previous month. To count the deviation I need to consider always the max – min between the current month and the previous month
For example, to February:

Rick_ferreira_1-1622452670578.png

And finally, I need to create the chart like this:

Rick_ferreira_2-1622452716044.png

I am trying but probably I am doing something wrong-

Does someone help me?

3 ACCEPTED SOLUTIONS
Fowmy
Super User
Super User

@Anonymous 

Create a Date table as it will help you with the time intelligence functions. Check the attached file.

Fowmy_0-1622455505140.png

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

I suggest having a dim-calendar table like below.

please check the below picture and the sample pbix file's link down below.

 

Picture1.png

 

Number of Sales Total =
SUM(Sales[No of Sales])
 
Deviation =
SUMX (
CROSSJOIN ( VALUES ( 'Calendar'[Month & Year] ), VALUES ( Sales[Product] ) ),
IF (
ISBLANK (
CALCULATE ( [Number of Sales Total], DATEADD ( 'Calendar'[Date], -1, MONTH ) )
),
BLANK (),
ABS (
[Number of Sales Total]
- CALCULATE ( [Number of Sales Total], DATEADD ( 'Calendar'[Date], -1, MONTH ) )
)
)
)
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

Hi, @Anonymous 

Please check the below.

 

Picture3.png

 

deviation CC =
VAR currentdate = Sales[Date]
VAR currentproduct = Sales[Product]
VAR previousdate =
CALCULATE (
MAX ( Sales[Date] ),
FILTER ( Sales, Sales[Product] = currentproduct && Sales[Date] < currentdate )
)
VAR previousnoofsales =
CALCULATE (
SUM ( Sales[No of Sales] ),
FILTER ( Sales, Sales[Product] = currentproduct && Sales[Date] = previousdate )
)
RETURN
IF (
NOT ISBLANK ( previousnoofsales ),
ABS ( Sales[No of Sales] - previousnoofsales )
)
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

8 REPLIES 8
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

I suggest having a dim-calendar table like below.

please check the below picture and the sample pbix file's link down below.

 

Picture1.png

 

Number of Sales Total =
SUM(Sales[No of Sales])
 
Deviation =
SUMX (
CROSSJOIN ( VALUES ( 'Calendar'[Month & Year] ), VALUES ( Sales[Product] ) ),
IF (
ISBLANK (
CALCULATE ( [Number of Sales Total], DATEADD ( 'Calendar'[Date], -1, MONTH ) )
),
BLANK (),
ABS (
[Number of Sales Total]
- CALCULATE ( [Number of Sales Total], DATEADD ( 'Calendar'[Date], -1, MONTH ) )
)
)
)
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Thank you so much.

I tried to do your advice but insted of create a measure I am creating a column using dax to add on table the desviation column but your rule doesn´t work.

Could you please explain me why?

Thanks

Hi, @Anonymous 

Thank you for your feedback.

I think you cannot use the formula for creating a column that is for creating a measure.

how does your expected outcome look like?


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

I would like to create a new column with desviation as your measure do. I want to create a columns like this:

Rick_ferreira_0-1622465483560.png

 

Hi, @Anonymous 

Please check the below.

 

Picture3.png

 

deviation CC =
VAR currentdate = Sales[Date]
VAR currentproduct = Sales[Product]
VAR previousdate =
CALCULATE (
MAX ( Sales[Date] ),
FILTER ( Sales, Sales[Product] = currentproduct && Sales[Date] < currentdate )
)
VAR previousnoofsales =
CALCULATE (
SUM ( Sales[No of Sales] ),
FILTER ( Sales, Sales[Product] = currentproduct && Sales[Date] = previousdate )
)
RETURN
IF (
NOT ISBLANK ( previousnoofsales ),
ABS ( Sales[No of Sales] - previousnoofsales )
)
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Fowmy
Super User
Super User

@Anonymous 

Create a Date table as it will help you with the time intelligence functions. Check the attached file.

Fowmy_0-1622455505140.png

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

selimovd
Super User
Super User

Hey @Anonymous ,

 

you can calculate the value from the last month and subtract that from the current month:

Deviation Last Month = SUM( myTable[No of Sales] ) - CALCULATE( SUM( myTable[No of Sales] ), DATEADD( myTable[Date], -1, MONTH ) )

 

This should work for your case.

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
Anonymous
Not applicable

Hello
Thanks, but you resolution doesn´t work.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors