Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi
This is driving me insane!
I have a table full of ID's with values for particular dates. I would like to create a new column which returns the previous value for each ID, but only if it is the previous month.
The dates are all the first date in the month. The example of what i would like to return is below
I've tried all sorts of code, none of which i can get to work!
Any help is greatly appreciated
Solved! Go to Solution.
@Gav10 , My mistake , it should me maxx
Previous value =
var _min = maxx(filter(Table,[ID] = earlier([ID]) && [Date] < earlier([Date]) ),[Date])
return
maxx(filter(Table,[ID] = earlier([ID]) && [Date] =_min),[Current Value])
@Gav10 ,
If this can help
Previous value =
VAR CurrentID = 'Previous Row DAX'[ID]
VAR PreviousMonth_1 =
PREVIOUSMONTH ( 'Previous Row DAX'[Date] )
VAR PreviousValue =
CALCULATE (
MAX ( 'Previous Row DAX'[Current value] ),
REMOVEFILTERS ('Previous Row DAX'),
CurrentID = 'Previous Row DAX'[ID],
PreviousMonth_1 = 'Previous Row DAX'[Date]
)
RETURN
PreviousValue
@Gav10 , Create a new column
Previous value =
var _min = minx(filter(Table,[ID] = earlier([ID]) && [Date] < earlier([Date]) ),[Date])
return
maxx(filter(Table,[ID] = earlier([ID]) && [Date] =_min),[Current Value])
Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8
Thanks but this doesn't work i'm afraid. It returns the value if it has changed over the time period and not what it was the previous month. See below
@Gav10 , My mistake , it should me maxx
Previous value =
var _min = maxx(filter(Table,[ID] = earlier([ID]) && [Date] < earlier([Date]) ),[Date])
return
maxx(filter(Table,[ID] = earlier([ID]) && [Date] =_min),[Current Value])
So unfortunately this still doesn't return the desired result.
It's finding the previous instance regardless of the date. I only want it to look at the previous month. So for September it should be showing blank and not 1 as there is no record of the ID in August