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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
sudershan
Regular Visitor

Row with min value within a category

Hi,

 

I have the following data:

S.No.Txn DateOpening Bal.Txn Amount
101-Jan-20221001000
201-Jan-20221100500
302-Jan-20221600800
402-Jan-20222400-300
503-Jan-20222100750

 

I need to get the row with min of S.No. for each category of Txn Date.  Or I need to get the Opening Bal. for each Txn Date in a separate query.

I tried Group By by Txn Date with Min of S.No.  but this does not give me the Opening Bal.

Thanks

1 ACCEPTED SOLUTION
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTLU9UrM0zUyAjENDCCkgVKsTrSSEZosRNoUKmsMZBshyZqBZS2gsiaoskYmYFldY6i0KZBjjCQNMdrcFCgbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"S.No." = _t, #"Txn Date" = _t, #"Opening Bal." = _t, #"Txn Amount" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"S.No.", Int64.Type}, {"Txn Date", type date}, {"Opening Bal.", Int64.Type}, {"Txn Amount", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Txn Date"}, {{"S.No.", each List.Min([#"S.No."]), type nullable number}}),
    #"Merged Queries" = Table.NestedJoin(#"Grouped Rows", {"S.No."}, #"Changed Type", {"S.No."}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"Opening Bal."}, {"Opening Bal."})
in
    #"Expanded Grouped Rows"

 👍 It's been a pleasure to help you | Help Hours: 11 AM to 9 PM (UTC+05:30)

How to get your questions answered quickly -- How to provide sample data

View solution in original post

1 REPLY 1
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately. If you have columns other than these, then delete Changed type step and do a Changed type for complete table from UI again)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTLU9UrM0zUyAjENDCCkgVKsTrSSEZosRNoUKmsMZBshyZqBZS2gsiaoskYmYFldY6i0KZBjjCQNMdrcFCgbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"S.No." = _t, #"Txn Date" = _t, #"Opening Bal." = _t, #"Txn Amount" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"S.No.", Int64.Type}, {"Txn Date", type date}, {"Opening Bal.", Int64.Type}, {"Txn Amount", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Txn Date"}, {{"S.No.", each List.Min([#"S.No."]), type nullable number}}),
    #"Merged Queries" = Table.NestedJoin(#"Grouped Rows", {"S.No."}, #"Changed Type", {"S.No."}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"Opening Bal."}, {"Opening Bal."})
in
    #"Expanded Grouped Rows"

 👍 It's been a pleasure to help you | Help Hours: 11 AM to 9 PM (UTC+05:30)

How to get your questions answered quickly -- How to provide sample data

Helpful resources

Announcements
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.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Users online (3,211)