Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hi all,
I am looking for help in creating an added column to a query where I have merged queries by date to show number of orders received and number of orders complete by date. The column I want to add is the to show number of orders remaining based on the previous balance + orders received - orders completed.
Thanks in advance
Solved! Go to Solution.
Hi Metalman1972,
Kindly follow the step-by-step approach outlined below, which may assist in resolving the issue:
#"Sorted Rows" = Table.Sort(#"YourPreviousStep", {{"Date", Order.Ascending}})
// Create a list of the running balance using List.Accumulate
RunningBalanceList = List.Accumulate(
#"Sorted Rows"[Orders Received],
{0}, // Initial value for balance
(state, current) => state & {List.Last(state) + current - #"Sorted Rows"[Orders Completed]{List.Count(state)-1}}
)
// Convert Running Balance List into a Column
#"Added Running Balance" = Table.FromColumns(
Table.ToColumns(#"Sorted Rows") & {List.RemoveFirstN(RunningBalanceList, 1)},
Table.ColumnNames(#"Sorted Rows") & {"Running Balance"}
)
#"Grouped By Date" = Table.Group(#"Added Running Balance", {"Date"}, {
{"Orders Received", each List.Sum([Orders Received]), type number},
{"Orders Completed", each List.Sum([Orders Completed]), type number},
{"Running Balance", each List.Max([Running Balance]), type number}
})
#"Sorted Final Table" = Table.Sort(#"Grouped By Date", {{"Date", Order.Ascending}})
Save the changes and refresh the dataflow to ensure that the running balance is computed correctly.
If you find this response helpful, kindly mark it as the accepted solution and provide kudos. This will aid other community members facing similar queries.
Thank you.
Hi Metalman1972,
Thank you for your kind patience.
Please find below the step-by-step solution to be implemented in the Advanced Editor:
If you find our response helpful, kindly mark it as the accepted solution and provide kudos. This will help other members of the community facing similar queries.
Should you have any further questions, please feel free to reach out to the Microsoft Fabric community.
Thank you.
Hi Metalman1972,
We are following up to confirm whether the solution provided have resolved your issue.
If you found our response helpful, kindly mark it as the accepted solution and provide kudos, as this benefits the larger community.
If you have discovered an alternative solution to the issue, we would appreciate it if you could share it with the community to assist others facing similar challenges.
Thank you.
Hi Metalman1972,
Thank you for your kind patience.
Please find below the step-by-step solution to be implemented in the Advanced Editor:
If you find our response helpful, kindly mark it as the accepted solution and provide kudos. This will help other members of the community facing similar queries.
Should you have any further questions, please feel free to reach out to the Microsoft Fabric community.
Thank you.
Hi Metalman1972,
We wanted to check in regarding your query, as we have not heard back from you. If you have resolved the issue, sharing the solution with the community would be greatly appreciated and could help others encountering similar challenges.
If you found our response useful, kindly mark it as the accepted solution and provide kudos to guide other members.
Thank you.
Hi Metalman1972,
We are following up to confirm whether the solutions provided have resolved your issue.
If you found our response helpful, kindly mark it as the accepted solution and provide kudos, as this benefits the larger community.
If you have discovered an alternative solution to the issue, we would appreciate it if you could share it with the community to assist others facing similar challenges.
Thank you.
Hi Metalman1972,
We wanted to check in regarding your query, as we have not heard back from you. If you have resolved the issue, sharing the solution with the community would be greatly appreciated and could help others encountering similar challenges.
If you found our response useful, kindly mark it as the accepted solution and provide kudos to guide other members.
Thank you.
Hi There,
I have been working with the solutions offered and I'm running into some difficulty intergrating it into my query using the advanced editor I've been getting errors that I'm working through.
Thanks again for the help.
Hi Metalman1972,
We have not received a response from you regarding the query and were following up to check if you have found a resolution. If you have identified a solution, we kindly request you to share it with the community, as it may be helpful to others facing a similar issue.
If you find the response helpful, please mark it as the accepted solution and provide kudos, as this will help other members with similar queries.
Thank you.
Hi Metalman1972,
Kindly follow the step-by-step approach outlined below, which may assist in resolving the issue:
#"Sorted Rows" = Table.Sort(#"YourPreviousStep", {{"Date", Order.Ascending}})
// Create a list of the running balance using List.Accumulate
RunningBalanceList = List.Accumulate(
#"Sorted Rows"[Orders Received],
{0}, // Initial value for balance
(state, current) => state & {List.Last(state) + current - #"Sorted Rows"[Orders Completed]{List.Count(state)-1}}
)
// Convert Running Balance List into a Column
#"Added Running Balance" = Table.FromColumns(
Table.ToColumns(#"Sorted Rows") & {List.RemoveFirstN(RunningBalanceList, 1)},
Table.ColumnNames(#"Sorted Rows") & {"Running Balance"}
)
#"Grouped By Date" = Table.Group(#"Added Running Balance", {"Date"}, {
{"Orders Received", each List.Sum([Orders Received]), type number},
{"Orders Completed", each List.Sum([Orders Completed]), type number},
{"Running Balance", each List.Max([Running Balance]), type number}
})
#"Sorted Final Table" = Table.Sort(#"Grouped By Date", {{"Date", Order.Ascending}})
Save the changes and refresh the dataflow to ensure that the running balance is computed correctly.
If you find this response helpful, kindly mark it as the accepted solution and provide kudos. This will aid other community members facing similar queries.
Thank you.
Thank you, @Akash_Varuna , for your response.
Hi @Metalman1972,
We sincerely appreciate your inquiry through the Microsoft Fabric Community Forum.
Based on your query, please find attached the PBIX file along with the expected output for your reference, which may assist in resolving the issue.
If you find our response helpful, kindly mark it as the accepted solution and consider providing kudos. This will help other community members facing similar queries.
Thank you.
Hi @Metalman1972 This can be done through calculated column after loading the data please follow these
Sort by Date:
Create a Calculated Column:
Go to the Modeling tab and create a New Column:
Remaining Orders =
VAR PreviousBalance =
CALCULATE(
SUM('Table'[Remaining Orders]),
FILTER(
'Table',
'Table'[Date] < EARLIER('Table'[Date])
)
)
RETURN
PreviousBalance + 'Table'[Orders Received] - 'Table'[Orders Completed]
Replace Table with your Table name and ensure you have Orders Completed Orders Recieved column or Replace those with your actual column
If this post helped please do give a kudos and accept this as a solution
Thanks In Advance
Hi There,
Many thanks for the help but I'm afraid this won't work for me as I cannot add a column on a direct query from a lakehouse dataset nor can I added it in the semantic model. this is why I was trying to create the column in a dataflow power query function.
Could you help with that??