Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
9 | |
8 | |
7 | |
7 |
User | Count |
---|---|
13 | |
11 | |
9 | |
6 | |
6 |