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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Newbie22
Resolver I
Resolver I

DAX Measure - Comparison of Monthly Volume Increase or Decrease

Hi! 

 

I've been a silent reader and this community have helped me with multiple solutions. However, this time I can't find the answer to my query.

 

First of all, I need to create a DAX comparison of volume per month (If the volume decreased or increased from the previous month) then I will have to create an icon using conditional formatting.

 

Example of format in Excel:

 

Newbie22_0-1661273876666.png

 

My Table in Power BI: Monthly Summary

Two Columns: Volume and Month

 

I'm using this measure but it's not working 😓

 

Condition_Volume =
VAR _val =
CALCULATE ( SUM ( 'Monthly Summary'[Volume] ) )
-
CALCULATE ( SUM ( 'Monthly Summary'[Volume] ),
PREVIOUSMONTH ( 'Monthly Summary'[Month] ) )

RETURN
SWITCH ( TRUE (),
_val < 0, -1,
_val = 0, 0,
_val > 0, 1 )

 

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

 

This is actually my first post here. I hope someone can help me. Thanks in advance!

 

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

 

I finally found the solution:

 

Sharing the code here in case someone needs it.

 

_Condition_Volume =
var monthly=sum('Monthly Summary'[Volume])
var Monthlyp= CALCULATE(SUM('Monthly Summary'[Volume]),CALCULATETABLE(DATEADD('Monthly Summary'[Date], -1,MONTH)))
var result=monthly-Monthlyp
var result2=Switch(True,
    result<0,-1,
    result=0,0,
    result>0,1)
return
result2
 
 Here's how it looks in my dashboard. You can finally see the decrease or increase comparison of volume each month 😊🙌
 
Newbie22_0-1662649849098.png

 

5 REPLIES 5
Anonymous
Not applicable

Hi Newbie22

Please try this measure to use afetr on the cond formatting.

JamesFr06_0-1661288815724.png

This is the table I built to to it "Feuil1"

JamesFr06_1-1661288871138.png

Here is the code

Variance =
var monthly=sum(Feuil1[Volume])
var Monthlyp=calculate([Monthly_volume],PREVIOUSMONTH('Date'[Date]))
var result=monthly-Monthlyp
var result2=Switch(True,
    result<0,-1,
    result=0,0,
    result>1,1)
return
result2

Hi JamesFr06,

 

Thanks for your reply.

 

I tried using your measure but I think I did something wrong?

 

Newbie22_0-1661326289529.png

 

This is the code:

 

_Condition_Volume =
var monthly=sum('Monthly Summary'[Volume])
var Monthlyp=calculate([Monthly_volume],PREVIOUSMONTH('Monthly Summary'[Month]))
var result=monthly-Monthlyp
var result2=Switch(True,
    result<0,-1,
    result=0,0,
    result>1,1)
return
result2
---------------------------------------------
 Note: I used below column for PREVIOUSMONTH
Newbie22_4-1661326598647.png

 

 -----------------------------------------
 
Here is the result when I visualize it using matrix:
March and April Volume should have red arrow since both volumes decreased. 
 
Newbie22_1-1661326358579.png

 

 Here's the screenshot of my conditional formatting for volume:
 
Newbie22_2-1661326445801.png

 

Please let me know if you needed more information. Thank you so much for the assistance. 😊

Anonymous
Not applicable

Hello @Newbie22

Thanks for your return. The only difference I see is on the calculation of previuos month. I worked with a date table and you you worked with a month column in the same table. Do you have one date table ? 

Hi @Anonymous 

 

Yes, I have another Date table (Calendar). Tried using that too and it's still not working. 

Newbie22_0-1661344541299.png

Newbie22_2-1661344878856.png

This time it returned to 0 (based on my icon)

 

I also noticed that you have created another measure named "Monthly_Volume". May I know your calculation? That could be our difference..

 

Here's the screenshot of your DAX:

 

Newbie22_1-1661344677952.png

 

I really appreciate your help to me. 🤗

 

Anonymous
Not applicable

Hi @Newbie22 

Please find the table I had created and the measure.

JamesFr06_0-1661345857935.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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