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 August 31st. Request your voucher.

Reply
GA1993
Helper II
Helper II

Difference of values between current and previous month

Is there a way to subtract the current and previous month?

 

I am trying to reuse a code given to me but I keep getting this error below... 

GA1993_0-1631227595259.png

 

The formula on excel is =IF((AW9-AW8)<=0,1,0)

 

and my data should be..

GA1993_1-1631227390637.png

 

Please your help yould be really appreciated!

1 ACCEPTED SOLUTION

@GA1993 

 

Close Sum formula with bracket ")".

try this:

Measure = 
Var _TM= Max([Start Date])
Var _LM = date(year(_TM),month(_TM)-1,day(_TM))
Var _This MonthV = Calculate(sum([Phising Website]),[Start Date]=TM)
Var _PrevMonthV = Calculate(sum([Phising Website]),[Start Date]=LM)
return
if(_This MonthV-_PrevMonthV<=0,1,0)

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos ✌️!!

 

 

View solution in original post

5 REPLIES 5
VahidDM
Super User
Super User

Hi @GA1993 

 

Does that Start date just have the first day of each month?

if no, can you share a sample of your data with more details as a table here
If yes, try this:

Measure = 
Var _TM= Max([Start Date])
Var _LM = date(year(_TM),month(_TM)-1,day(_TM))
Var _This MonthV = Calculate(sum([Phising Website],[Start Date]=TM)
Var _PrevMonthV = Calculate(sum([Phising Website],[Start Date]=LM)
return
if(_This MonthV-_PrevMonthV<=0,1,0)


If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos✌️!!



 

 

Hi, it doesnt need to be the first day of each month. I

 

t's more of like the values under the Start Date talks about each month (ie 2018-07, 2018-08, 2018-09, and so on)

 

GA1993_0-1631247428924.png

 

The following is the logic behing it:

AW(10) Phishing website value (current month) - 

AW(9) Phishing website value (previous month)

 

If (value above <= 0 , 1, 0)

 

I hope this helps...

 

Also, I tried your formula but I am getting the following error.. Am I doing something wrong?

 

GA1993_1-1631247841757.png

 

@GA1993 

 

Close Sum formula with bracket ")".

try this:

Measure = 
Var _TM= Max([Start Date])
Var _LM = date(year(_TM),month(_TM)-1,day(_TM))
Var _This MonthV = Calculate(sum([Phising Website]),[Start Date]=TM)
Var _PrevMonthV = Calculate(sum([Phising Website]),[Start Date]=LM)
return
if(_This MonthV-_PrevMonthV<=0,1,0)

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos ✌️!!

 

 

Thank you! It worked for this. However, when I reused the code for the other fields because it has the same formula, the error below kept popping up...

 

Is there any workaround for this?

 

GA1993_0-1631250396313.png

 

Hi @GA1993 

 

Please see below links:

https://www.sqlbi.com/articles/avoiding-circular-dependency-errors-in-dax/

https://www.sqlbi.com/articles/understanding-circular-dependencies/

https://community.powerbi.com/t5/Desktop/quot-A-circular-Dependency-was-detected-quot-error-while/td...

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos ✌️!!

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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