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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Fromit
Regular Visitor

Selecting the last version

Good morning.
I have a database with the issued offers, the keys of the records consist of the offer number and the version of the offer.
Every time we generate an quotation it creates a record and every time we modify it a new version is generated, so we have the 1365 quotation with versions 1, 2 and 3, the 1366 with versions 1 and 2 and the 1367 with versions 1, 2, 3 and 4.
The only ones I am interested in selecting are the last versions of each offer, the 1365/3, 1366/2 and 1367/4, the others I want to skip them from analysis.
Can someone help me to filter and select the records I need?
Is there any instruction for this?
Thank you very much.

2 REPLIES 2
AlB
Super User
Super User

Hi @Fromit 

Can you share some sample data. It will the be easy to build a solution

Share it in text-tabular format so that the contents can be copied

I'm assuming you want this in Power Query? or DAX?

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Vijay_A_Verma
Super User
Super User

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XY6xDcAgDAR3cU0DNo9TJmsg9l8DozgRuPgvXqeze6fMqJQoW1isbhrpX4tF1er5VjgrFTsMh0UizBZoZBcm573mZiCuS9x2b3OvXsdv6oZcXsOY", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Quotation = _t, Version = _t, #"Time Taken" = _t, Location = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Quotation", Int64.Type}, {"Version", Int64.Type}}),
    BuffZipList = List.Zip({#"Changed Type"[Quotation],#"Changed Type"[Version]}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Max(List.Transform(List.Select(BuffZipList, (x)=>x{0}=[Quotation]), each _{1}))=[Version]),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = true)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom"})
in
    #"Removed Columns"

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors