cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
actroyani
Regular Visitor

Check if a value exists previously

Hi,

I would like to know how to create a new column where I get the value "New" if a person exists in previous months of my data and "Old" if it exists in previous months or if it's the first month of data.

I have a table like this:

DatePerson
15/11/2021A
13/11/2021A
12/11/2021B
10/11/2021C
20/10/2021A
15/10/2021C
10/10/2021C
15/09/2021A

Take into account that individuals may appear more than once on a month, so this is what I would like:

DatePersonColumn
15/11/2021AOld
13/11/2021AOld
12/11/2021BNew
10/11/2021COld
20/10/2021AOld
15/10/2021CNew
10/10/2021CNew
15/09/2021ANew

Thanks in advance!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@actroyani ,

a new column =

var _1 = countx(filter(Table, [Person] = earlier([Person]) && [Date] < earlier([Date] ) ), [Person]) +0

return

if(_1 > 0, "Old", "New")



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@actroyani ,

a new column =

var _1 = countx(filter(Table, [Person] = earlier([Person]) && [Date] < earlier([Date] ) ), [Person]) +0

return

if(_1 > 0, "Old", "New")



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors