cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ajaygajree Frequent Visitor
Frequent Visitor

Create a Column using DAX that flags if a row existed in the previous month based on a ID Field

Hi All

 

I want to create a Column that flags if a record existed in the previous month, so that if it didn't I can exclude it from the current months calculations.

 

ID     Month

1       Jun-19

2       Jun-19

3       Jun-19

4       Jun-19

1       May-19

2       May-19

3      May-19

So in the example above, I want 3rd Column that tells me for example that ID 4 did not exist in May

I want to do this for every record

 

Any guidance appreciated!

 

3 REPLIES 3
Super User
Super User

Re: Create a Column using DAX that flags if a row existed in the previous month based on a ID Field

What is the data type of the Month column?

 

Best

Darek

ajaygajree Frequent Visitor
Frequent Visitor

Re: Create a Column using DAX that flags if a row existed in the previous month based on a ID Field

Date/Time

Super User
Super User

Re: Create a Column using DAX that flags if a row existed in the previous month based on a ID Field

[Existed In Prev Month] = -- calculated column
-- T[Month] must be the first day of the month
var __currentMonth = T[Month]
var __currentID = T[ID]
-- This moves the MONTH to be the first day
-- of the prior month.
var __prevMonth = EDATE ( __currentMonth, -1 )
var __existedInPrevMonth =
	not isempty(
		filter(
			T,
			T[ID] = __currentID,
			T[Month] = __prevMonth 
		)
	)
return
	__existedInPrevMonth

Best

Darek

Helpful resources

Announcements
Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Power BI Helps Homeless and Trouble Youth

Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 47 members 1,039 guests
Please welcome our newest community members: