I'm very new to DAX and tabular models and I've managed to get stumped on what will be a fairly common problem that we will face. Consider the following scenario (not my actual scenario, but the same problem in a scenario that is easy to understand without lots of explanation):Sales and customer tables are linked on Customer_Key. We want to find the Sales_ID for the biggest value sale (Sales_Value) and put that as a column in the Customer table. This will be used in an SSRS report to return the biggest value sale in a date range defined by the end user. I can figure out how to return the biggest value sale, but now how to then use that to return the Sales_ID for that value (keeping in mind that more than one customer may happen to have a sale of the same value).Were I facing this problem in an SQL query, I'd simply produce a sub-query as follows:[code="sql"]SELECT Sales_IDFROM (SELECT Sales_ID, ROW_NUMBER() OVER(PARTITION BY Customer_Key ORDER BY Sales_Value Desc) AS R FROM Sales WHERE Sale_Date BETWEEN @ReportStartDate AND @ReportEndDate ) AS SubWHERE R = 1[/code]What would be the equivalent DAX solution?ThanksStuart
↧