Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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...
The formula on excel is =IF((AW9-AW8)<=0,1,0)
and my data should be..
Please your help yould be really appreciated!
Solved! Go to Solution.
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 ✌️!!
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)
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?
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?
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/
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos ✌️!!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
12 | |
10 | |
10 | |
6 |