If/Then and look up in same formula...must be an easier way

franathive

New Member
Joined
Mar 8, 2018
Messages
4
Hi,
I have the following situation. I am trying to look up months and currency conversion rates. I have a table which I am maintaining that looks like this.

1/1/20182/1/20183/1/20184/1/20185/1/2018etc
GBP1.21.31.41.51.6
EUR1.21.251.261.271.28
USD11111

<tbody>
</tbody>

On a different tab, I have a list of invoices.
It looks like this:
Customer NAME
Customer A
INVOICE DATE
1/15/2018
Current drop down
GBP
I want this column to be a formula driven
1.2
Customer B3/15/2018EUR1.26
Customer C2/5/2018USD1
Customer D1/17/2018GBP1.2

<tbody>
</tbody>

There must be an easier way than if/then and < and > symbols. These formulas are getting long.
Basically, I have lookup currency on chart, if invoice date is greater than x and less than y, then z. But it is getting cumbersome. Am I missing something easy?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi,

How about this:

Change/adjust formula with your Tab name where your Table is.


Book1
ABCDEF
11/1/20182/1/20183/1/20184/1/20185/1/2018
2GBP1.21.31.41.51.6
3EUR1.21.251.261.271.28
4USD11111
5
6
7Customer NAMEINVOICE DATECurrent drop down
8Customer A1/15/2018GBP1.2
9Customer B3/15/2018EUR1.26
10Customer C2/5/2018USD1
11Customer D1/17/2018GBP1.2
Sheet6
Cell Formulas
RangeFormula
D8=SUMPRODUCT((B$1:F$1=LOOKUP(B8,B$1:F$1))*(A$2:A$4=C8)*(B$2:F$4))


Formula copied down.
 
Upvote 0
Thank you so much! This worked like a charm. I do feel a bit like it's a black hole. What confuses me about your formula-how does Excel know that 1/15/2018 goes to 1/1/2018 as it is not a one to one match?

I can't figure out how your formula works and replaces my ridiculously long one! I will use it but any insight is appreciated. Thank you. As for the other poster who posted the Index and Match, I have never used those commands but did think that was the way to go. I will use the first formula simply because I think I'll be able to understand how it works with a bit of research. I hate to use a formula I don't understand.

You guys are amazing. Thank you!

Hi,

How about this:

Change/adjust formula with your Tab name where your Table is.

ABCDEF
11/1/20182/1/20183/1/20184/1/20185/1/2018
2GBP1.21.31.41.51.6
3EUR1.21.251.261.271.28
4USD11111
5
6
7Customer NAMEINVOICE DATECurrent drop down
8Customer A1/15/2018GBP1.2
9Customer B3/15/2018EUR1.26
10Customer C2/5/2018USD1
11Customer D1/17/2018GBP1.2

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet6

Worksheet Formulas
CellFormula
D8=SUMPRODUCT((B$1:F$1=LOOKUP(B8,B$1:F$1))*(A$2:A$4=C8)*(B$2:F$4))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



Formula copied down.
 
Upvote 0
Thank you so much! This worked like a charm.-how does Excel know that 1/15/2018 goes to 1/1/2018 as it is not a one to one match?

I think I'll be able to understand how it works with a bit of research. I hate to use a formula I don't understand.

You guys are amazing. Thank you!

You're welcome, welcome to the forum.

The LOOKUP function within my formula looks for B8 (1/15/2018) in the range B1:F1, as long as the range is in ascending order, and since LOOKUP cannot find an exact match for 1/15/2018, it returns the next Smaller value, in this case 1/1/2018.
 
Upvote 0
That makes perfect sense. Thank you...this is why I use the word FALSE in formulas...because I usually want an exact match. Funny, I always thought it was odd and wondered why someone would need something that wasn't an exact match. This is the perfect example!! Thank you for all your help. Very much appreciated.
You're welcome, welcome to the forum.

The LOOKUP function within my formula looks for B8 (1/15/2018) in the range B1:F1, as long as the range is in ascending order, and since LOOKUP cannot find an exact match for 1/15/2018, it returns the next Smaller value, in this case 1/1/2018.
 
Upvote 0

Forum statistics

Threads
1,214,940
Messages
6,122,356
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top