I’m having trouble with the M code for creating a new column in Power Query Editor.
I have a query called ‘Call Outcomes’.
I want to create a column in ‘Call Outcomes’ called ‘Total Sales’ that sums the sales for the customer that are in the ‘Sales’ query.
However, I only want the total sales for each customer based on the following criteria:
‘Converted’ = Yes
If Converted = Yes, then sum sales only from the ‘Converted Date’
For example:
for Customer ID = 407627, Converted = No so Total Sales will be blank/zero
for Customer ID = 386535, Converted = Yes and Converted Date = 01/12/2022 so Total Sales will be those sales made on or after 01/12/2022 which in this case is $40
I’m trying to achieve this calculation in Power Query because the actual Sales table is large and I’d prefer not to import it into Power BI.
I don’t have access to the source data. I tried the aggregated table solution but it was quite slow.
I then tried manipulating the source data in Power Query and solved the issue using Group By with multiple conditions and then merge queries with multiple conditions.
I should have thought about this earlier but my headspace was elsewhere.