In powerbi How do i go from this
to this
my logic is to use a new column insted of a measure, becouse its static values
#lastmonth =
var lastmonth = format(DATEADD(X[Datum],-1,MONTH),"YYYY-MM-DD")
var rowmonth = FORMAT(X[Datum],"YYYY-MM-DD")
return
IF(FORMAT(X,"YYYY-MM-DD") = lastmonth, X[Value])
i know this can't be becouse the date can never be the same as the lastmonth.. but i cant figuere it out.
With Calculated Column, when you need data from other rows, then you will need to come out of the row context. This is can be done in a number of ways, here are a couple of examples:
Using REMOVEFILTERS()
:
#lastmonth =
var prevMonth = DATEADD( X[Datum], -1, MONTH )
RETURN
CALCULATE(
MIN(X[Value]),
REMOVEFILTERS(),
X[Description] = EARLIER(X[Description]) && X[Datum] = prevMonth
)
Or an alternative:
#lastmonth =
var prevMonth = DATEADD( X[Datum], -1, MONTH )
RETURN
CALCULATE(
MIN(X[Value]),
ALLEXCEPT(X, X[Description]),
X[Datum] = prevMonth
)