I want The lowest (minimum) and the highest (maximum) amount of total sales with criteria

Rsdg

New Member
Joined
Jul 7, 2022
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
hello guys , i have a data that include this columns , and i want to know the lowest and highest sale for city 1 in these 5 month , that's mean formula must sum the sale of city 1 for 5 month Individually and show the lowest sale


Book1
ABCDEFGH
1monthcity codesalecity codeThe lowest amount of total sales in these 5 months (minimum)The highest amount of total sales in these 5 months (maximum)
22021-01115,526,8701
32021-01121,578,6332
42021-0113,337,7803
52021-0121,897,163
62021-01314,323,674
72021-01315,268,137
82021-02154,982,451
92021-02112,425,854
102021-02212,432,354
112021-0227,812,365
122021-032951,327
132021-0321,500,369
142021-0331,946,358
152021-03321,499,128
162021-0334,551,746
172021-03335,896,412
182021-0414,000,365
192021-0411,500,000
202021-0412,500,005
212021-0413,125,844
222021-0511,000,000
232021-0512,000,000
242021-0525,648,565
252021-0523,669,540
262021-05215,268,700
272021-05215,264,471
282021-05213,543,658
292021-05313,131,239
302021-05325,688,845
Sheet1
 

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.
This requires an array formula for Excel 2016. After typing in the formula, do not hit ENTER--hit CTRL+SHIFT+ENTER. You have done it correctly if the formula in the formula box has {braces} around it. You cannot type in the braces; they are just an indicator that it is an array formula.

$scratch.xlsm
FGH
1city codeThe lowest amount of total sales in these 5 months (minimum)The highest amount of total sales in these 5 months (maximum)
211,000,00054,982,451
32951,32715,268,700
431,946,35835,896,412
Sheet3
Cell Formulas
RangeFormula
G2:G4G2=MIN(IF($B$2:$B$30=$F2,$C$2:$C$30,MAX($C:$C)))
H2:H4H2=MAX(IF($B$2:$B$30=$F2,$C$2:$C$30,0))
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0
This requires an array formula for Excel 2016. After typing in the formula, do not hit ENTER--hit CTRL+SHIFT+ENTER. You have done it correctly if the formula in the formula box has {braces} around it. You cannot type in the braces; they are just an indicator that it is an array formula.

$scratch.xlsm
FGH
1city codeThe lowest amount of total sales in these 5 months (minimum)The highest amount of total sales in these 5 months (maximum)
211,000,00054,982,451
32951,32715,268,700
431,946,35835,896,412
Sheet3
Cell Formulas
RangeFormula
G2:G4G2=MIN(IF($B$2:$B$30=$F2,$C$2:$C$30,MAX($C:$C)))
H2:H4H2=MAX(IF($B$2:$B$30=$F2,$C$2:$C$30,0))
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
thanks , but i think i did not explain well , this formula shows me the lowest value in city 1 , but i want the lowest value between months for city 1 , for example your formula shows 1.000.000 but in 2022.05 total sale for city 1 is 3.000.000 That should Comparison with another months for city 1 , thanks again
 
Upvote 0
So you want to find the total sales by month for each city for each month, and return the lowest/highest monthly total?
 
Upvote 0
Trying to understand your needs. My interpretation

Book5
ABCDEFGHIJK
1monthcity codesalecity codemonthTotal Salescity codeLowest SaleHighest Sale
22021-0111552687012021-01404432831300000067408305
32021-0112157863322021-0118971632189716353394934
42021-011333778032021-012959181132959181163893644
52021-012189716312021-0267408305
62021-0131432367422021-0220244719
72021-0131526813722021-032451696
82021-0215498245132021-0363893644
92021-0211242585412021-0411126214
102021-0221243235412021-053000000
112021-022781236522021-0553394934
122021-03295132732021-0538820084
132021-0321500369
142021-0331946358
152021-03321499128
162021-0334551746
172021-03335896412
182021-0414000365
192021-0411500000
202021-0412500005
212021-0413125844
222021-0511000000
232021-0512000000
242021-0525648565
252021-0523669540
262021-05215268700
272021-05215264471
282021-05213543658
292021-05313131239
302021-05325688845
Sheet1


This is a power query solution that requires two different queries.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"sale", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"city code", "month"}, {{"Total Sales", each List.Sum([sale]), type nullable number}})
in
    #"Grouped Rows"

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"sale", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"city code", "month"}, {{"Total Sales", each List.Sum([sale]), type nullable number}}),
    #"Grouped Rows1" = Table.Group(#"Grouped Rows", {"city code"}, {{"Lowest Sale", each List.Min([Total Sales]), type nullable number}, {"Highest Sale", each List.Max([Total Sales]), type nullable number}})
in
    #"Grouped Rows1"
 
Upvote 0
Solution
Trying to understand your needs. My interpretation

Book5
ABCDEFGHIJK
1monthcity codesalecity codemonthTotal Salescity codeLowest SaleHighest Sale
22021-0111552687012021-01404432831300000067408305
32021-0112157863322021-0118971632189716353394934
42021-011333778032021-012959181132959181163893644
52021-012189716312021-0267408305
62021-0131432367422021-0220244719
72021-0131526813722021-032451696
82021-0215498245132021-0363893644
92021-0211242585412021-0411126214
102021-0221243235412021-053000000
112021-022781236522021-0553394934
122021-03295132732021-0538820084
132021-0321500369
142021-0331946358
152021-03321499128
162021-0334551746
172021-03335896412
182021-0414000365
192021-0411500000
202021-0412500005
212021-0413125844
222021-0511000000
232021-0512000000
242021-0525648565
252021-0523669540
262021-05215268700
272021-05215264471
282021-05213543658
292021-05313131239
302021-05325688845
Sheet1


This is a power query solution that requires two different queries.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"sale", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"city code", "month"}, {{"Total Sales", each List.Sum([sale]), type nullable number}})
in
    #"Grouped Rows"

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"sale", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"city code", "month"}, {{"Total Sales", each List.Sum([sale]), type nullable number}}),
    #"Grouped Rows1" = Table.Group(#"Grouped Rows", {"city code"}, {{"Lowest Sale", each List.Min([Total Sales]), type nullable number}, {"Highest Sale", each List.Max([Total Sales]), type nullable number}})
in
    #"Grouped Rows1"
thanks, I think this is the solution , But I am trying to understand Because I am not familiar with power Query, thank you again
 
Upvote 0
This should help to understand Power Query

Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

- Follow this link to learn how to install Power Query in Excel 2010 / 2013.

- Follow this link for an introduction to Power Query functionality.

- Follow this link for a video which demonstrates how to use Power Query code provided.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,190
Members
452,616
Latest member
intern444

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