Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
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")
User | Count |
---|---|
88 | |
82 | |
43 | |
40 | |
35 |