Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Good afternoon, I am fairly new to PowerBi and probably have a simple question. Thank you very much for your response.
Create a measurement that shows the opening balance of the lowest number per date |
Eg the lowest index of 1-1-2022 is 12033 , the value shown should then be 3424.31 |
Eg the lowest index of 2-1-2022 is 12038 , the value shown should then be 3300,21 |
Date | Number | Description | Opening Balance | Transaction | Closing Balance |
1-1-2022 | 12034 | Diversen | € 3.349,31 | € 58.933,81 | € 62.283,12 |
1-1-2022 | 12033 | Schoen | € 3.424,31 | € -75,00 | € 3.349,31 |
1-1-2022 | 12035 | Laars | € 62.283,12 | € 2.593,09 | € 64.876,21 |
1-1-2022 | 12037 | Diversen | € 64.826,21 | € -61.526,00 | € 3.300,21 |
1-1-2022 | 12036 | Jas | € 64.876,21 | € -50,00 | € 64.826,21 |
2-1-2022 | 12039 | Diversen | € 3.299,21 | € -1,00 | € 3.298,21 |
2-1-2022 | 12038 | Diversen | € 3.300,21 | € -1,00 | € 3.299,21 |
3-1-2022 | 12043 | Broek | € 2.870,82 | € -135,45 | € 2.735,37 |
3-1-2022 | 12042 | Trui | € 2.996,52 | € -125,70 | € 2.870,82 |
3-1-2022 | 12041 | Jas | € 3.170,26 | € -173,74 | € 2.996,52 |
3-1-2022 | 12040 | Jas | € 3.298,21 | € -127,95 | € 3.170,26 |
Solved! Go to Solution.
Hi @AlfredvdM ,
how do you want this number to be shown? As an additional column to the existing data in each row?
Then you could use this code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZA9TwMxDIb/S+arG9v58oqYKjbYqhtO6CQqJCrdCX5/46TQXEknO4mf19FzPBrc454skRkMkmWX6/PpZ17W+Su3zE6AMXc+CTMkbQNRYkAy4/CP51xf3z/OlXbkKr2LvknrcPr8Mk3L2uYPhrwwWNFLl2IA6sJx++k8SmU07w3oKZTV1j6g9fkwre2ODHrbJilGW0zuTJHIFcV6TA/AdK+4/uwGyi/IG9Cp26flPH+qmBQtJCoUe3Dqj2LusowOqvVt+T7plEgAX0nyEJuwDoh/chjzUHG5w8gQXZPVAe0NvKooCyOIb8LG8QI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Number = _t, Description = _t, #" Opening Balance" = _t, Transaction = _t, #"Closing Balance" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Number", Int64.Type}, {"Description", type text}, {" Opening Balance", type number}, {"Transaction", type number}, {"Closing Balance", type number}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Date", "Number", "Description"}, {{"MinOpening", each List.Min([#" Opening Balance"]), type nullable number}, {"Partition", each _, type table [Date=nullable date, Number=nullable number, Description=nullable text, #" Opening Balance"=nullable number, Transaction=nullable number, Closing Balance=nullable number]}}),
#"Expanded Partition" = Table.ExpandTableColumn(#"Grouped Rows", "Partition", {" Opening Balance", "Transaction", "Closing Balance"}, {" Opening Balance", "Transaction", "Closing Balance"})
in
#"Expanded Partition"
Please also check the file enclosed.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi Imke, That's the right solution. Thanks a Lot!!
gr Alfred
Hi @AlfredvdM ,
yes, my bad.
Please try this solution:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZA9TwMxDIb/S+arG9v58oqYKjbYqhtO6CQqJCrdCX5/46TQXEknO4mf19FzPBrc454skRkMkmWX6/PpZ17W+Su3zE6AMXc+CTMkbQNRYkAy4/CP51xf3z/OlXbkKr2LvknrcPr8Mk3L2uYPhrwwWNFLl2IA6sJx++k8SmU07w3oKZTV1j6g9fkwre2ODHrbJilGW0zuTJHIFcV6TA/AdK+4/uwGyi/IG9Cp26flPH+qmBQtJCoUe3Dqj2LusowOqvVt+T7plEgAX0nyEJuwDoh/chjzUHG5w8gQXZPVAe0NvKooCyOIb8LG8QI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Number = _t, Description = _t, #"Opening Balance" = _t, Transaction = _t, #"Closing Balance" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Number", Int64.Type}, {"Description", type text}, {"Opening Balance", type number}, {"Transaction", type number}, {"Closing Balance", type number}}),
#"Grouped Rows" = Table.Group(
#"Changed Type",
{"Date"},
{
{"OpeningPerDate", each Table.Buffer(Table.Sort(_, {"Number", Order.Ascending})){0}[Opening Balance]},
{"ClosingPerDate", each Table.Buffer(Table.Sort(_, {"Number", Order.Descending})){0}[Closing Balance]},
{
"Partition",
each _,
type table [
Date = nullable date,
Number = nullable number,
Description = nullable text,
#" Opening Balance" = nullable number,
Transaction = nullable number,
Closing Balance = nullable number
]
}
}
),
#"Expanded Partition" = Table.ExpandTableColumn(
#"Grouped Rows",
"Partition",
{"Opening Balance", "Transaction", "Closing Balance"},
{"Opening Balance", "Transaction", "Closing Balance"}
)
in
#"Expanded Partition"
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi Imke,
Thanks a lot for yout input. I probably have to redefine my question.
1. There are several transactions per date
2. Therefore I need the correct openingbalance for that specific date.
3. The correct openingbalance for that date is the one with the lowest value in column [number].
Note: not the minimum value of the openingsbalance itself
Date | Number | Description | Opening Balance | Transaction | Closing Balance | OpeningBalancePerDate | ClosingBalancePerDate |
1-1-2022 | 12033 | Schoen | € 3.424,31 | € -75,00 | € 3.349,31 | € 3.424,31 | € 3.300,21 |
1-1-2022 | 12034 | Diversen | € 3.349,31 | € 58.933,81 | € 62.283,12 | € 3.424,31 | € 3.300,21 |
1-1-2022 | 12035 | Laars | € 62.283,12 | € 2.593,09 | € 64.876,21 | € 3.424,31 | € 3.300,21 |
1-1-2022 | 12036 | Jas | € 64.876,21 | € -50,00 | € 64.826,21 | € 3.424,31 | € 3.300,21 |
1-1-2022 | 12037 | Diversen | € 64.826,21 | € -61.526,00 | € 3.300,21 | € 3.424,31 | € 3.300,21 |
2-1-2022 | 12038 | Diversen | € 3.300,21 | € -1,00 | € 3.299,21 | € 3.300,21 | € 3.298,21 |
2-1-2022 | 12039 | Diversen | € 3.299,21 | € -1,00 | € 3.298,21 | € 3.300,21 | € 3.298,21 |
So, per 1-1-2022 is the correct openingbalance the one with number 12033 (the lowest number of date 1-1-22), and that is 3.424,31.
Why? If I add the transactions to the opening balance, I get the correct closing balance for that specific date.
I hope I explained it clearly.
Many thanks in advance for the effort.
Gr Alfred
Hi @AlfredvdM ,
how do you want this number to be shown? As an additional column to the existing data in each row?
Then you could use this code:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZA9TwMxDIb/S+arG9v58oqYKjbYqhtO6CQqJCrdCX5/46TQXEknO4mf19FzPBrc454skRkMkmWX6/PpZ17W+Su3zE6AMXc+CTMkbQNRYkAy4/CP51xf3z/OlXbkKr2LvknrcPr8Mk3L2uYPhrwwWNFLl2IA6sJx++k8SmU07w3oKZTV1j6g9fkwre2ODHrbJilGW0zuTJHIFcV6TA/AdK+4/uwGyi/IG9Cp26flPH+qmBQtJCoUe3Dqj2LusowOqvVt+T7plEgAX0nyEJuwDoh/chjzUHG5w8gQXZPVAe0NvKooCyOIb8LG8QI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Number = _t, Description = _t, #" Opening Balance" = _t, Transaction = _t, #"Closing Balance" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Number", Int64.Type}, {"Description", type text}, {" Opening Balance", type number}, {"Transaction", type number}, {"Closing Balance", type number}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Date", "Number", "Description"}, {{"MinOpening", each List.Min([#" Opening Balance"]), type nullable number}, {"Partition", each _, type table [Date=nullable date, Number=nullable number, Description=nullable text, #" Opening Balance"=nullable number, Transaction=nullable number, Closing Balance=nullable number]}}),
#"Expanded Partition" = Table.ExpandTableColumn(#"Grouped Rows", "Partition", {" Opening Balance", "Transaction", "Closing Balance"}, {" Opening Balance", "Transaction", "Closing Balance"})
in
#"Expanded Partition"
Please also check the file enclosed.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries