Forum Discussion
Anonymous
7 years agoNot applicable
Assistance required with formulating Measures
New to Power BI and working with DAX Formulas. I'm trying to work with three formulas. The first would provide me with the customer that purchased the greatest amount of a part number during a spec...
- Anonymous7 years agoHi again, I belive your problem is that you are not using a Customer table that is related to your Sales_Analysis table like I am, and when you put that into the TOPN function it will just contain all the rows of that table. Hence, if you more than one row with the same customer name it will be duplicated. If you have a customer table then you should use that instead, or you could try to replace 'Sales_Analysis' with VALUES('Sales_Analysis'[Customer]) in the TOPN function. Best regards, Kristjan
Anonymous
7 years agoNot applicable
Hi there,
Maybe this will solve your problem, you will have to change the names of the columns and the measures. This measure will show the top 1 customer that bought the most in the current context. Hence, if you will put the part number in the matrix it should show the top 1 customer for each part, if the model is correctly connected. This will apply to the dates as well, i.e. top 1 customer for the dates in current context, you can override the context with a CALCULATE in the TOPN function, to filter on this year or the last.
Top 1 cust =
PATHITEM(
CONCATENATEX(
TOPN(
3;
'Sales Customers';
[$ sales]
);
'Sales Customers'[CustomerName];
"|";
[$ sales];DESC
);
1 // Just changed this to 2 and 3 for the other measures
)
If this solves your problem you please LIKE and accept this as solution.
Best regards,
Kristjan76
Anonymous
7 years agoNot applicable
First off, many thanks to you for take ng the time to assist me with my questions and provide a possible code correction. I adjusted the proposed formula just a bit and it is pulling the data but is duplicating some of the return values. I would have replied sooner but was testing it out late yesterday evening and have been delayed with other work this morning. I will reply within the hour with further details and the code adaptation.