Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
gmasta1129
Resolver I
Resolver I

Find if a date changes

Hello, 

 

I have a report that contains 3 columns

 

1. Run Date

2. Portfolio Code

3. Maturity Date

 

I am trying to create a formula to show if there is a difference in the maturity date column from one day to the next by portfolio code. 

Please see table below for reference. 

From Run Date 10/6/2025 to 10/7/2025, the date changed to 6/30/2028. Therefore the new column should show a "Y".  

From Run Date 10/7/2025 to 10/8/2025, the date changed again to 6/27/2027. Therefore the new column should show a "Y".  If there is no change then a "N" should show.  

 

Run Datefacility codematurity dateDate Change? 
10/1/2025718036/27/2027N
10/2/2025718036/27/2027N
10/3/2025718036/27/2027N
10/6/2025718036/27/2027N
10/7/2025718036/30/2028Y
10/8/2025718036/27/2027Y
10/9/2025718036/27/2027N
10/10/2025718036/27/2027N

 

 

Can someone please help with the formula? 

 

Thanks in advance for your help. 

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

ThxAlot_0-1760127807161.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

7 REPLIES 7
gmasta1129
Resolver I
Resolver I

Hello @ThxAlot ,

 

This worked perfectly. Thank you so much for your help. I appreciate it. 

raisurrahman
Helper II
Helper II

@gmasta1129:
Thanks to @ronrsnfld  and @AntrikshSharma for their Power Query solutions—both work perfectly. For very large datasets, I’d recommend @ronrsnfld's approach; it’s faster than @AntrikshSharma ’s, because the latter transforms the object multiple times (Table → Record → Table). 

Kedar_Pande
Super User
Super User

  

Add a calculated column:

Date Change? =
VAR CurrentPortfolio = 'Table'[Portfolio Code]
VAR PreviousDate =
CALCULATE(
MAX('Table'[Maturity Date]),
FILTER(
'Table',
'Table'[Portfolio Code] = CurrentPortfolio &&
'Table'[Run Date] < EARLIER('Table'[Run Date])
)
)
RETURN
IF('Table'[Maturity Date] <> PreviousDate && NOT ISBLANK(PreviousDate), "Y", "N")
 

@gmasta1129

AntrikshSharma
Community Champion
Community Champion

@gmasta1129  Try this:

 

let
    Source = Excel.CurrentWorkbook(){[ Name = "Table1" ]}[Content],
    ChangedType = Table.TransformColumnTypes (
        Source,
        { { "Run Date", type date }, { "facility code", Int64.Type }, { "maturity date", type date } }
    ),
    Recs = Table.ToRecords ( ChangedType ),
    Acc = List.Accumulate (
        List.Skip ( Recs ),
        { List.First ( Recs, 1 ) & [ Date Change = "N" ] },
        ( s, c ) =>
            s
                & {
                    if List.Last ( s )[#"maturity date"] <> c[#"maturity date"] then
                        c & [ Date Change = "Y" ]
                    else
                        c & [ Date Change = "N" ]
                }
    ),
    Result = Table.FromRecords (
        Acc,
        type table [ Run Date = date, facility code = Int64.Type, maturity date = date, Date Change = text ]
    )
in
    Result

 

Excel file attached below.

ronrsnfld
Super User
Super User

In Power Query, you can add an Index column to refer to the previous row.

 

Paste the below code into the Advanced Editor to see how it works:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTQN9Q3MjAyVdJRMje0MDAG0mb6RuYgMXOlWB2wCiOCKowJqjAjqMIcU4WxAUjMAqbCgqAZlgRVGBrgURILAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Run Date" = _t, #"facility code" = _t, #"maturity date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Run Date", type date}, {"facility code", Int64.Type}, {"maturity date", type date}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Change?", each 
        if [Index] = 0 then "N" 
        else if #"Changed Type"[maturity date]{[Index]-1} = [maturity date] then "N" else "Y", type text)
in
    #"Added Custom"
SundarRaj
Super User
Super User

Hi @gmasta1129,
In case you'd like to do this query on Power Query. Here's a solution that you can refer to. Let me know in case there are any confusions. Thanks

SundarRaj_0-1760185717363.png

Code:
let
Source = [SourceData],
Group = Table.Group(
Source,
{"facility code"},
{
{
"AllRows",
each
let
AddColumn = Table.AddIndexColumn(_, "Due Date?", 0, 1),
Transform = Table.TransformColumns(
AddColumn,
{
"Due Date?",
each try AddColumn[maturity date]{_ - 1} otherwise AddColumn[maturity date]{_}
}
),
DueColumn = Table.AddColumn(
Transform,
"Due Date",
each if [maturity date] = [#"Due Date?"] then "N" else "Y"
)
in
DueColumn
}
}
),
Combine = Table.Combine(Group[AllRows])
in
Combine

Sundar Rajagopalan
ThxAlot
Super User
Super User

ThxAlot_0-1760127807161.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.