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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Mat42
Resolver I
Resolver I

Latest Date Financial Year

This feels both simple and probably not possible all at the same time.

 

So, this is basically my dataset:

Mat42_0-1731059504406.png

I used the following M to create the Latest column, which displays a 1 if the date is the latest for each Code:

 

if [Date] = List.Max(let currentCode = [Code]
in Table.SelectRows(#"Renamed Columns",
each [Code] = currentCode)[Date])
then 1
else 0

 

And it works. But now they've decided they want a 1 alongside every date that is the latest date for each financial year, so the dataset would look like this:

Mat42_0-1731068428665.png

 

To demonstrate: for code 11111 there is a 1 alongside 02/03/2024 because it is the latest date in financial year 2023-2024 and alongside 01/05/2024 because it is the latest date in financial year 2024-2025. Both entries for 33333 have a 1 because each entry is the latest (and only) date in separate financial years.

 

They want this done in Power Query for reasons they haven't yet told me.

 

Is this possible? I don't mind adding in new columns or merging tables if I need to.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Angith_Nair ,
According to your question, we have tried other methods, based on your actual data, I hope to help you with your question!
Our first step is to find the maximum date under each fiscal year, which we call MAXTable.

vxingshenmsft_0-1731378657359.png

Then we merger with the original table to get a MaxDate, which is the maximum date value for each fiscal year.

vxingshenmsft_1-1731378711187.png

 


And finally, we add a new column to find out if each ID is the latest date.

vxingshenmsft_2-1731378731641.png

I hope this helps you solve your problem, if you have further questions you can check out the uploaded pbix, I'd be incredibly proud to solve your query!

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

6 REPLIES 6
FreemanZ
Community Champion
Community Champion

hi @Mat42 ,

 

try like:

if 

[Date] = 

List.Max(

    let currentCode = [Code], currentyear = [FinYear]

    in Table.SelectRows(

       #"Renamed Columns",

        each [Code] = currentCode and each [FinYear] = currentyear )[Date]

)

then 1

else 0

Thanks for replying.

 

The code is getting flagged at this point:

 

Mat42_0-1731078511332.png

Token Literal expected

Angith_Nair
Continued Contributor
Continued Contributor

Hi @Mat42 

 

Create a financial year column that identifies the financial year for each Date.

AddFinancialYear = Table.AddColumn(#"Renamed Columns", "FinancialYear", each if Date.Month([Date]) >= 4 then Date.Year([Date]) + 1 else Date.Year([Date]), Int64.Type)

Modify the logic as per the financial year:

AddLatestFlag = Table.AddColumn(AddFinancialYear, "Latest", each 
    if [Date] = List.Max(
        Table.SelectRows(AddFinancialYear, each [Code] = [Code] and [FinancialYear] = [FinancialYear])[Date]
    ) then 1
    else 0)

Hi, thanks.

 

I tried this and I've ended up like this (this is the actual data):

 

Mat42_1-1731080477587.png

I'd expect a 1 to be alongside 10000215136 and 1000025230 because they are the latest date for each financial year because they are the only entries, and for 1000025429 there should be a 1 against 21/002/2024 because that is the latest date in financial year 2023/2024 and a 1 against 19/06/2024 because it is the latest date in 2024/2025.

Anonymous
Not applicable

Hi @Angith_Nair ,
According to your question, we have tried other methods, based on your actual data, I hope to help you with your question!
Our first step is to find the maximum date under each fiscal year, which we call MAXTable.

vxingshenmsft_0-1731378657359.png

Then we merger with the original table to get a MaxDate, which is the maximum date value for each fiscal year.

vxingshenmsft_1-1731378711187.png

 


And finally, we add a new column to find out if each ID is the latest date.

vxingshenmsft_2-1731378731641.png

I hope this helps you solve your problem, if you have further questions you can check out the uploaded pbix, I'd be incredibly proud to solve your query!

Hope it helps!

Best regards,
Community Support Team_ Tom Shen

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

You are awesome!

 

Although this didn't quite do what I needed because it gave me the latest date rather than the latest financial date, I actually removed a financial year column from the dataset, so I used that instead of 'Year' for the grouping and it worked great. 

 

Thanks!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.