Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have the following data:
S.No. | Txn Date | Opening Bal. | Txn Amount |
1 | 01-Jan-2022 | 100 | 1000 |
2 | 01-Jan-2022 | 1100 | 500 |
3 | 02-Jan-2022 | 1600 | 800 |
4 | 02-Jan-2022 | 2400 | -300 |
5 | 03-Jan-2022 | 2100 | 750 |
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
Solved! Go to Solution.
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
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
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
10 | |
7 | |
7 | |
6 | |
6 |