Forum Discussion
vvenditt
5 years agoNew Member
get value from the previous month
hello, hope you all are well! I have a problem in a DAX measure.
I need to capture the previous result.
normally I would use DATEADD or PREVIOUSMONTH for this, but my problem is:
in my example, I do...
- 5 years ago
tks
vvenditt
5 years agoNew Member
Thank you very much for your help. the material will help me as a reference, but I still haven't been able to solve my problem.
the main point here is this:
if I'm evaluating the line of period 4, I want to compare it with period 3, but if there is no value in period 3, I want to compare it to period 2.
in my case I do not need to accumulate, but rather pay the amount prior to the period of the valuation contextvvenditt
5 years agoNew Member
hello I managed to solve it with this DAX code:
previous result =
var period_context = MAX (data [period])
var previous_period =
CALCULATE(
MAX (data [period]),
FILTER(
ALL (data [period]),
data [period] <period_context &&
SUM (data [value]) <> BLANK ()
)
)
var previous_month_value =
CALCULATE(
SUM (data [value]),
FILTER(
ALL (data [period]),
data [period] = previous_period
)
)
Return
if(
ISINSCOPE (data [period]),
previous_month_value
)- vvenditt5 years agoNew Member
tks