Link to home
Start Free TrialLog in
Avatar of Karen Schaefer
Karen SchaeferFlag for United States of America

asked on

Syntax help - translating actual column/field names to test sample SumProduct returning wrong value

I had this question after viewing For Loop for Excel 2016 vba.


I am attempting to modify the tested version to handle the actual column names in my worksheet and I am getting a #Value issue

=IF(Country_Billing[agtno]=B1,qryDifference[agtno],SUMPRODUCT((qryDifference[agtno]=Country_Billing[agtno])*(qryDifference[Validate Adjustment]="Y")*qryDifference[Difference])+Country_Billing[agt_amt])

Open in new window


The working version from the test sample.

=IF([@agtno]=B1,qryDifference[agtno],SUMPRODUCT((Balance!$B$2:$B$7=[@agtno])*(Balance!$F$2:$F$7="Y")*Balance!$E$2:$E$7)+[@[agt_amt]])

Open in new window


User generated image
Highlight number should be the new value, what am I missing.  could it be the SumProduct returning wrong value
Avatar of Arana (G.P.)
Arana (G.P.)

you should enclose sheet names in brackets (the whole thing not just the table data column name)
=Country_Billing[agtno] should be =[Country_Billing@agtno] (this from same workbook)
 
=testsample.xlsx!Table1[@agtno]    This from another book , notice filename is first THEN ! sign    then complete table reference

I see you are also missing some of the @ signs that identify table columns
Avatar of Karen Schaefer

ASKER

what if the referencing of a table that is linked to another query.  The table is based on an query,  what is the proper syntax?
ok here is what I have so far and get error:
User generated image
Problem seems to be with the +[@Column1] part in the formula.

Also qualify the cell references with Table Name e.g.  change [@agentno] to country_results[@agentno] and same with other cell references in the formula.
so How do I get the revised agt_amount?  for the first instances of the AgentNo only?

=IF(qryDifference[agentno]=Country_results[agentno],qryDifference[agentno],SUMPRODUCT((qryDifference[agentno]=Country_results[@agentno])*(qryDifference[Validate Adjustment]="Y")*qryDifference[New Adj Amt])+Country_results[agt_amt])

the new amount = First value per agentno plus the difference value on a different sheet within the same workbook. and if validataion is null then return the original value .

NOTE:  The references are what the system places when I click on the column to make sure I have it correct.

I will also need to modify the tot_leads amount where the validation = Y.

User generated image
Did the formula you posted in your last post work for you?
As I said the problem would be with +Country_results[agt_amt] part.
it would return a result some times but not the correct value.
Found solution with help of another ee posting.
ASKER CERTIFIED SOLUTION
Avatar of Karen Schaefer
Karen Schaefer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
found the solution elsewhere on ee