Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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 ✌️!!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |