Forum Discussion
Dax to M
Hi Everyone,
I am trying to conver this Dax to M however I have not been successful any help will be much appreciated!
3 Replies
- edhansCommunity Champion
You don't do lookupvalue in M, you do merges, then return the column(s) you need, then do any further comparisons. See this article for how to do a merge. That is what a VLOOKUP or LOOKUPVALUE is doing on getting a value in table a, finding it table b, then returning column X.
Post back with actual data samples if you need further help on this.
How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum - daxCommunity Support
Hi DanMyers ,
I am not clear about your requirement, you could try to refer to edhans 's suggestions to use merge. By the way, if possible could you please inform me more detailed information(such as your expected output and your sample data (by OneDrive for Business))? Then I will help you more correctly.
Please do mask sensitive data before uploading.
Thanks for your understanding and support.
Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- JohnThomasHelper II
Dan,
Here's a Lookup Function for Power Query. I believe it will get you what you need.
/* Source: https://www.excelguru.ca/blog/2015/01/28/creating-a-vlookup-function-in-power-query */ let pqVLOOKUP = (lookup_value as any, table_array as table, col_index_number as number, optional approximate_match as logical ) as any => let /*Provide optional match if user didn't */ matchtype = if approximate_match = null then true else approximate_match, /*Get name of return column */ Cols = Table.ColumnNames(table_array), ColTable = Table.FromList(Cols, Splitter.SplitByNothing(), null, null, ExtraValues.Error), ColName_match = Record.Field(ColTable{0},"Column1"), ColName_return = Record.Field(ColTable{col_index_number - 1},"Column1"), /*Find closest match */ SortData = Table.Sort(table_array,{{ColName_match, Order.Descending}}), RenameLookupCol = Table.RenameColumns(SortData,{{ColName_match, "Lookup"}}), RemoveExcess = Table.SelectRows(RenameLookupCol, each [Lookup] <= lookup_value), ClosestMatch= if Table.IsEmpty(RemoveExcess)=true then "#N/A" else Record.Field(RemoveExcess{0},"Lookup"), /*What should be returned in case of approximate match? */ ClosestReturn= if Table.IsEmpty(RemoveExcess)=true then "#N/A" else Record.Field(RemoveExcess{0},ColName_return), /*Modify result if we need an exact match */ Return = if matchtype=true then ClosestReturn else if lookup_value = ClosestMatch then ClosestReturn else "#N/A" in Return in pqVLOOKUPThis Function is by Ken Puls. See documentation on the function here: https://www.excelguru.ca/blog/2015/01/28/creating-a-vlookup-function-in-power-query
Another good source is Matt Allington's website and blog post which is here.
Hope this helps!
John