Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

create alias table

Hello,   I am trying to create a dashboard using a User Group attendance list. Attendees fill up a form where they type their role. But each of them will type what they feel like so I get multipl...
  • stretcharm's avatar
    stretcharm
    8 years ago

    I've tweaked the fnVLookup to just do a text match search and pick the first entry by an order.

     

    (lookup_value as any, table_array as table, col_index_number as number, optional array_order_column as number) as any =>
    let
    
    /*Provide optional sort column if user didn't */
    sortColNo  =
    if array_order_column  = null
    then 0
    else array_order_column - 1 ,
    
    /*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"),
    ColName_Sort = Record.Field(ColTable{sortColNo}, "Column1"),
    
    /*Find closest match */
    SortData = Table.Sort(table_array,{{ColName_Sort, Order.Ascending}}),
    RenameLookupCol = Table.RenameColumns(SortData ,{{ColName_match, "Lookup"}}),
    Matches = Table.SelectRows(RenameLookupCol, each Text.Contains(lookup_value, [Lookup])),
    
    Return = if Table.IsEmpty(Matches)=true
    then "#N/A"
    else Record.Field(Matches{0}, ColName_return)
    in Return