Using Choose or some other method to choose between Formulas

Vaslo

Board Regular
Joined
Jun 3, 2009
Messages
159
Hello,

I have a spreadsheet that selects from one of four places depending on the variation of two criteria (Whether I want to look at Sales or Gallons and whether I want the Actual or the Forecast)

I have a formula I use below, but its quite long. I know CHOOSE() is a way to shorten functions. I don't know of a way to use CHOOSE() with Index/Match and can't seem to dig anything up. Is there a way to use CHOOSE() to change the table you are selecting, or is there a better way?


Code:
=IF(AND(N$2="Actual",$O$1="Sales"),SUMIFS(RawData[SumOfNet Invoiced Amount at AFX],RawData[CalendarMonth],N$3,RawData[Product Number],$S6,RawData[Profit Center Code],$F$4,RawData[Customer Name],$A$1),
IF(AND(N$2="Actual",$O$1="Gallons"),SUMIFS(RawData[SumOfNet Quantity in GAL],RawData[CalendarMonth],N$3,RawData[Product Number],$S6,RawData[Profit Center Code],$F$4,RawData[Customer Name],$A$1),
IF(AND(N$2="Forecast",$O$1="Sales"),SUMIFS(FoodFcst[Gross Sales],FoodFcst[FcstMonth],N$3,FoodFcst[Product '# as text],$S6,FoodFcst[Customer],$A$1),
IF(AND(N$2="Forecast",$O$1="Gallons"),SUMIFS(FoodFcst[Volume],FoodFcst[FcstMonth],N$3,FoodFcst[Product '# as text],$S6,FoodFcst[Customer],$A$1),
999))))
 

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.
Perhaps (untested) :-
Code:
=IF(N$2="Actual",SUMIFS(INDEX((RawData[SumOfNet Invoiced Amount at AFX],RawData[SumOfNet Quantity in GAL]),,,IF($O$1="Sales",1,IF($O$1="Gallons",2))),RawData[CalendarMonth],N$3,RawData[Product Number],$S6,RawData[Profit Center Code],$F$4,RawData[Customer Name],$A$1),
IF(N$2="Forecast",SUMIFS(INDEX((FoodFcst[Gross Sales],FoodFcst[Volume]),,,IF($O$1="Sales",1,IF($O$1="Gallons",2))),FoodFcst[FcstMonth],N$3,FoodFcst[Product '# as text],$S6,FoodFcst[Customer],$A$1),999))

hth
 
Upvote 0

Forum statistics

Threads
1,214,665
Messages
6,120,804
Members
448,990
Latest member
rohitsomani

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