Forum Discussion
yfquirogah
Helper I
6 years agoPrevious month value, not numerical
I'm using the example another person posted but I'm looking for a different solutions. "Hi Community, I have a table of employee IDs and their Pay Grades each month. I'm trying to create a ...
- 6 years ago
yfquirogah - Perhaps:
Previous Month = VAR __EmployeeID = [EmployeeID] VAR __CurrentDate = [Calendar Date] VAR __PreviousDate = MAXX(FILTER('Table',[Employee ID] = __EmployeeID && [Calendar Date] < __CurrentDate),[Calendar Date]) RETURN MAXX(FILTER('Table',[Employee ID] = __EmployeeID && [Calendar Date] = __PreviousDate),[Pay Grade]) - 6 years ago
Hi yfquirogah
try column
CALCULATE(LASTNONBLANK(Table[Pay Grade], 1), FILTER(ALL(Table), Table[Employee ID] = EARLIER(Table[Employee ID]) && Table[Calendar Date] = DATEADD(EARLIER(Table[Calendar Date]), -1, MONTH) ) )
Greg_Deckler
Community Champion
6 years agoyfquirogah - Perhaps:
Previous Month =
VAR __EmployeeID = [EmployeeID]
VAR __CurrentDate = [Calendar Date]
VAR __PreviousDate = MAXX(FILTER('Table',[Employee ID] = __EmployeeID && [Calendar Date] < __CurrentDate),[Calendar Date])
RETURN
MAXX(FILTER('Table',[Employee ID] = __EmployeeID && [Calendar Date] = __PreviousDate),[Pay Grade])yfquirogah
Helper I
6 years agoWonderful! It worked perfectly. I haven't learned to use varibles in Power BI yet but will definitely look into it, it was a lot easier than what I had tried so far.
Thank you!
- Greg_Deckler6 years ago
Community Champion
yfquirogah - Yes, variables are a must in my opinion, they break calculations down into manageable pieces, make the code more readable and enable troubleshooting. Highly recommended!