Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
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_ | FY | Status (desired results) |
| 011872 | FY-20 | NEW |
| 006104 | FY-20 | NEW |
| 146318 | FY-20 | NEW |
| 002702 | FY-20 | NEW |
| 001449 | FY-21 | NEW |
| 014478 | FY-21 | NEW |
| 006104 | FY-21 | OLD |
| 016876 | FY-21 | NEW |
| 002702 | FY-21 | OLD |
| 134890 | FY-21 | NEW |
| 000143 | FY-21 | NEW |
| 008019 | FY-21 | NEW |
| 106009 | FY-22 | NEW |
| 083291 | FY-22 | NEW |
| 000143 | FY-22 | OLD |
| 002906 | FY-22 | NEW |
| 000292 | FY-22 | NEW |
| 001449 | FY-22 | OLD |
| 006817 | FY-22 | NEW |
| 014478 | FY-22 | OLD |
Solved! Go to Solution.
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")
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.
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.
What if there is more than one previous row?
Change =1 to >=1
Hi @lavdeepk ,
if you need a measure you can do it like this:
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)
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")
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 64 | |
| 53 | |
| 42 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 121 | |
| 103 | |
| 46 | |
| 30 | |
| 24 |