cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lavdeepk
Helper III
Helper III

How to identify new and Old Txn based on Previous year data ?

Hi

 

I need your help to create a calculated column.

 

Refer to the below sample data I have year-wise txn I want to categorize all txn based on condition. if any ref no exists in last year txn then mark it as "OLD"  Else "NEW"  in the  Status field . (refer to desired results )

 

Ref  No_FYStatus (desired results)
011872FY-20NEW
006104FY-20NEW
146318FY-20NEW
002702FY-20NEW
001449FY-21NEW
014478FY-21NEW
006104FY-21OLD
016876FY-21NEW
002702FY-21OLD
134890FY-21NEW
000143FY-21NEW
008019FY-21NEW
106009FY-22NEW
083291FY-22NEW
000143FY-22OLD
002906FY-22NEW
000292FY-22NEW
001449FY-22OLD
006817FY-22NEW
014478FY-22OLD

 

2 ACCEPTED SOLUTIONS
lbendlin
Super User III
Super User III

You didn't specify if you wanted a measure or a calculated column. Here is a calculated column.

 

Status = 
var r = 'Table'[Ref  No_]
var f = 'Table'[FY]
var c = CALCULATE(COUNTROWS('Table'),All('Table'),'Table'[Ref  No_]=r,'Table'[FY]<f)
return if(c=0,"New","Old")

View solution in original post

Ashish_Mathur
Super User III
Super User III

Hi,

This calculated column formula works

=if(CALCULATE(COUNTROWS(Data),FILTER(data,Data[Ref  No_]=EARLIER(Data[Ref  No_])&&Data[FY]<EARLIER(Data[FY])))=1,"Old","New")

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User III
Super User III

Hi,

This calculated column formula works

=if(CALCULATE(COUNTROWS(Data),FILTER(data,Data[Ref  No_]=EARLIER(Data[Ref  No_])&&Data[FY]<EARLIER(Data[FY])))=1,"Old","New")

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

What if there is more than one previous row?

Change =1 to >=1


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
FrankAT
Super User II
Super User II

Hi @lavdeepk ,

if you need a measure you can do it like this:

 

24-07-_2021_00-20-02.png

 

Status = 
VAR _Min =
    CALCULATE ( MIN ( 'Table'[FY] ), ALLEXCEPT ( 'Table', 'Table'[Ref  No_] ) )
RETURN
    IF ( MIN ( 'Table'[FY] ) = _Min, "New", "Old" )

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

lbendlin
Super User III
Super User III

You didn't specify if you wanted a measure or a calculated column. Here is a calculated column.

 

Status = 
var r = 'Table'[Ref  No_]
var f = 'Table'[FY]
var c = CALCULATE(COUNTROWS('Table'),All('Table'),'Table'[Ref  No_]=r,'Table'[FY]<f)
return if(c=0,"New","Old")

View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors