I have this piece of code to pull data from a SharePoint and put it into a collection called 'SpendData'. The collection is made by taking a list of retailers and adding two columns, 'SearchAmount' and 'iMediaAmount' and giving these columns values based on another list, 'Data'. The reason why I don't create the collection based on 'Data' alone is because new retailers may not be included in the list.
ClearCollect(SpendData,ShowColumns(AddColumns(RetailerList,
"SearchAmount",
0 + If(Approved,LookUp(Data,Retailer=RetailerList[@Title]&&Title=CategoryV).CurrentAmount,LookUp(Data,Retailer=RetailerList[@Title]&&Title=CategoryV).PendingAmount),
"iMediaAmount",
0 + If(Approved,LookUp(Data,Retailer=RetailerList[@Title]&&Title=CategoryV).iMedia_x002f_OtherCurrent ,LookUp(Data,Retailer=RetailerList[@Title]&&Title=CategoryV).iMedia_x002f_OtherPending)),"Title","SearchAmount","iMediaAmount")
I have two main issues with this code:
-In the 'If' statements, I repeat the lookup for each condition. Is there any way that I can do the lookup and have the if statement simply decide which attribute to pull.
- The code runs slow, sometimes taking 13 seconds to load which is a little annoying. Is there anything I can do to speed this up?
Is there anything I can do to make this more concise and/or faster? Thank you for your help.