Forum Discussion
Power Query / DAX equivalent to Excel's Index Match with Dynamic Array
- 6 years ago
Ok emcalleja , try this. And I apologize if I mangle the field meanings due to them being in not English. 😂
This measure works I think.
Price = VAR varCurrentDate = MAX( Salidas[Fecha de movimiento] ) VAR varCurrentItem = MAX( Salidas[Nombre] ) VAR varEntradasData = FILTER( Entradas, Entradas[Nombre] = varCurrentItem && Entradas[Fecha de movimiento] <= varCurrentDate ) VAR varEntradasMaxDate = MAXX( varEntradasData, [Fecha de movimiento] ) VAR varPrice = MAXX( FILTER( varEntradasData, [Fecha de movimiento] = varEntradasMaxDate ), [Costo / Venta] ) RETURN varPriceThe problem is you need a bit of modeling. See my PBIX. file. It returns this:
Here is what I did
- I got all of the names (nombres?) from both tables and put them in a Names table, then removed duplicates. The problem is you have some case sensitivity issues, so I had to change case to "proper" because to Power Query, Car <> CAR <> CaR. DAX doesn't care. Power Query does.
- I used hte Name table as my 1-many in the relationship shown here:
-
- Then I created and used that measure in the table visual above. I am pretty sure this can be optimized, but shoudl get you started.
emcalleja - See if this helps: https://community.powerbi.com/t5/Community-Blog/Excel-to-DAX-Translation/ba-p/1060991
Otherwise sample data and expected result would help. Please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.