Forum Discussion
Look up existing table to map value - Help understanding the formula
Hi newbie156 ,
Based on your description and the formulas provided, first is an explanation for what the above code does: ComponentFieldsBuffered[#“Creditors_Detailed.Total Due to Supplier”]{ComponentRowNumber}: this part selects a specific value from the ComponentFieldsBuffered table, which is determined by the row number specified by ComponentRowNumber. It is checking if the value in the “Creditors_Detailed.Total Due to Supplier” column is 0.
AccountMappingTable[Full.COGS Acct]{ReceiptComponentRowNumber}: this part looks up the value of the “Full.COGS Acct” column from the AccountMappingTable table using the ReceiptComponentRowNumber row number.
Text.From(...) & “-SD00006-100335----”: if the condition is true, the account number looked up is converted to text and a static string is appended.
else “11320-SD00006-100335----”: if the condition is false, use another static string.
For the second table, you want to use ReceiptesFields.Payment Mode to find the corresponding account in the CustomerPaymentMethodTableValue table. If there are no matches, then “N/A” should be returned. The following are similar formulas that you might use:
let
// Assuming ReceiptesFields is a table and Payment Mode is a column in that table
PaymentMode = ReceiptesFields[Payment Mode],
// Lookup the corresponding account in the CustomerPaymentMethodTableValue
LookupResult = Table.First(CustomerPaymentMethodTableValue, each _["CustomerReceipts_Detailed.Payment Mode"] = PaymentMode),
// Check if the lookup was successful
Account = if LookupResult is not null then LookupResult["Customer Receipt D365"] else "N/A"
in
Account
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly