A Different way to Calculate Ratios using GDC & or MIN ?

StrawberryDreams

Board Regular
Joined
Mar 26, 2022
Messages
75
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
  3. Mobile
Simply put , what is the best formula to write Ratios for both 2 numbers, and 3 or more numbers ?

I've tried using GDC and MIN on both 2 and 3 number ratios and both formulas can be broken. They either don't properly get the lowest number as 1, or they show DIV/O errors, or GDC panics when using decimals. Is there a bullet proof formula so I can get any possibility to work ?

Is there a better way to do what I want ? You can see in the example the yellow cells are the "problem cells."


Basic data calculator test 9.4.xlsm
ABCDEFG
1Value 1Value 2Value 3Ratio using GDC ( Value 1 & 2 )Ratio using MIN ( Value 1 & 2 )Ratio formula for three or more numbers ? GCDRatio formula for three or more numbers ? Using MIN
292329 : 231 : 2.569 : 23 : 24.5 : 11.5 : 1
3239223 : 92.56 : 123 : 9 : 211.5 : 4.5 : 1
427329 : 19 : 127 : 3 : 213.5 : 1.5 : 1
532791 : 91 : 91 : 9 : 31 : 9 : 3
640.521 : 0.1258 : 12 : 0.25 : 18 : 1 : 4
70.5400.125 : 11 : 80.125 : 1 : 0#DIV/0!
80.00890.230.1234#DIV/0!1 : 25.84#DIV/0!1 : 25.84 : 13.87
9000Nil#DIV/0!Nil#DIV/0!
10001Nil#DIV/0!Nil#DIV/0!
110100 : 1#DIV/0!0 : 1 : 0#DIV/0!
121001 : 0#DIV/0!1 : 0#DIV/0!
131011 : 0#DIV/0!1 : 0#DIV/0!
140110 : 1#DIV/0!0 : 1 : 1#DIV/0!
Sheet1
Cell Formulas
RangeFormula
D2:D14D2=IF(B2=0,IF(A2=0,"Nil",A2&" : "&0),A2/GCD(A2:B2)&" : "&B2/GCD(A2:B2))
E2:E14E2=ROUND(A2/MIN(A2,B2),2) & " : " & ROUND(B2/MIN(A2,B2),2)
F2:F14F2=IF(B2=0,IF(A2=0,"Nil",A2&" : "&0),A2/GCD(A2:C2)&" : "&B2/GCD(A2:C2)&" : "&C2/GCD(A2:C2))
G2:G14G2=ROUND(A2/MIN(A2,B2,C2),2) & " : " & ROUND(B2/MIN(A2,B2,C2),2) & " : " & ROUND(C2/MIN(A2,B2,C2),2)
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Cell F10 Should also be yellow and rather show instead 0 : 0 : 1

I think the cleanest looking ratio is when the lowest number in the range is displayed as "1", and the other numbers' calculated values are divided by the original lowest number. Unless there are zeros which then the values should be written as a zero / and or the other non zero values can be simplified to their lowest ratio along with placing the zero for the values that have zero.

8 0 2 = 4 0 1
 
Last edited:
Upvote 0
@StrawberryDreams Doe this help?

Cell Formulas
RangeFormula
D2:D14D2=IF(SUM(A2:B2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:B2/MIN(IF(A2:B2=0,999,A2:B2)),2)))
E2:E14E2=IF(SUM(A2:C2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:C2/MIN(IF(A2:C2=0,999,A2:C2)),2)))
 
Upvote 1
Solution
@StrawberryDreams Doe this help?

Cell Formulas
RangeFormula
D2:D14D2=IF(SUM(A2:B2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:B2/MIN(IF(A2:B2=0,999,A2:B2)),2)))
E2:E14E2=IF(SUM(A2:C2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:C2/MIN(IF(A2:C2=0,999,A2:C2)),2)))
This looks squeaky clean! Let me play with it and see if anything pops up - but tbh looks bullet proof ! Cheers
 
Upvote 0
@StrawberryDreams Doe this help?

Cell Formulas
RangeFormula
D2:D14D2=IF(SUM(A2:B2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:B2/MIN(IF(A2:B2=0,999,A2:B2)),2)))
E2:E14E2=IF(SUM(A2:C2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:C2/MIN(IF(A2:C2=0,999,A2:C2)),2)))
Hi just thought of a question, If my Values are not in a nice horizontal or vertical range ( in different cells that are separate from one another ) will this still work if I just add each value separated by a comma , and for the sum formula just add + inbetween each cell value ?
 
Upvote 0
Book1
ABCDE
1Value 1Value 2Value 32 Numbers3 Numbers
292321 : 2.564.5 : 11.5 : 1
323922.56 : 111.5 : 4.5 : 1
427329 : 113.5 : 1.5 : 1
532791 : 91 : 9 : 3
640.528 : 18 : 1 : 4
70.5401 : 81 : 8 : 0
80.00890.230.12341 : 25.841 : 25.84 : 13.87
9000NilNil
10001Nil0 : 0 : 1
110100 : 10 : 1 : 0
121001 : 01 : 0 : 0
131011 : 01 : 0 : 1
140110 : 10 : 1 : 1
15>>>>>>>>3 : 9 : 1
Sheet1
Cell Formulas
RangeFormula
D2:D14D2=IF(SUM(A2:B2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:B2/MIN(IF(A2:B2=0,999,A2:B2)),2)))
E2:E14E2=IF(SUM(A2:C2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:C2/MIN(IF(A2:C2=0,999,A2:C2)),2)))
E15E15=LET(arry,HSTACK(B3,B5,A5),IF(SUM(arry)=0,"Nil",TEXTJOIN(" : ",,ROUND(arry/MIN(IF(arry=0,999,arry)),2))))
formula below in E15 for an idea on that scenario.
 
Upvote 0
Book1
ABCDE
1Value 1Value 2Value 32 Numbers3 Numbers
292321 : 2.564.5 : 11.5 : 1
323922.56 : 111.5 : 4.5 : 1
427329 : 113.5 : 1.5 : 1
532791 : 91 : 9 : 3
640.528 : 18 : 1 : 4
70.5401 : 81 : 8 : 0
80.00890.230.12341 : 25.841 : 25.84 : 13.87
9000NilNil
10001Nil0 : 0 : 1
110100 : 10 : 1 : 0
121001 : 01 : 0 : 0
131011 : 01 : 0 : 1
140110 : 10 : 1 : 1
15>>>>>>>>3 : 9 : 1
Sheet1
Cell Formulas
RangeFormula
D2:D14D2=IF(SUM(A2:B2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:B2/MIN(IF(A2:B2=0,999,A2:B2)),2)))
E2:E14E2=IF(SUM(A2:C2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:C2/MIN(IF(A2:C2=0,999,A2:C2)),2)))
E15E15=LET(arry,HSTACK(B3,B5,A5),IF(SUM(arry)=0,"Nil",TEXTJOIN(" : ",,ROUND(arry/MIN(IF(arry=0,999,arry)),2))))
formula below in E15 for an idea on that scenario.
Thanks I'll look at that case tooo... I found something with your original formula which calculates values with zero not the way Im hoping can be done. I provided a column with the errors showing how I would like them displayed if possible while including the solutions for the other possibilities.

Basic data calculator test 9.4.xlsm
ABCDEFG
1Value 1Value 2Value 32 #3 ##2 want#3 want
23011 : 03 : 0 : 13: 0
33103 : 13 : 1 : 0
40230 : 10 : 1 : 1.50 : 2
53001 : 01 : 0 : 03 : 03: 0 : 0
6003Nil0 : 0 : 10 : 0 : 3
Sheet2
Cell Formulas
RangeFormula
D2:D6D2=IF(SUM(A2:B2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:B2/MIN(IF(A2:B2=0,999,A2:B2)),2)))
E2:E6E2=IF(SUM(A2:C2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:C2/MIN(IF(A2:C2=0,999,A2:C2)),2)))
 
Upvote 0
Reason Why I want the "3" to be 3 and not 1 mathematically is to describe Parts
Example 3 eggs 0 flour. 0 sugar. I still have 3 parts eggs to zero other parts not 1:0:0

but if it was 3 eggs 2 flour 4 sugar - then the ratio would be 1.5 : 1 : 2 parts of ingredients
Cheers
 
Upvote 0
Book1
ABCDE
1Value 1Value 2Value 32 Numbers3 Numbers
292321 : 2.564.5 : 11.5 : 1
323922.56 : 111.5 : 4.5 : 1
427329 : 113.5 : 1.5 : 1
532791 : 91 : 9 : 3
640.528 : 18 : 1 : 4
70.5401 : 81 : 8 : 0
80.00890.230.12341 : 25.841 : 25.84 : 13.87
9000NilNil
10001Nil0 : 0 : 1
110100 : 10 : 1 : 0
121001 : 01 : 0 : 0
131011 : 01 : 0 : 1
140110 : 10 : 1 : 1
15>>>>>>>>3 : 9 : 1
Sheet1
Cell Formulas
RangeFormula
D2:D14D2=IF(SUM(A2:B2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:B2/MIN(IF(A2:B2=0,999,A2:B2)),2)))
E2:E14E2=IF(SUM(A2:C2)=0,"Nil",TEXTJOIN(" : ",,ROUND(A2:C2/MIN(IF(A2:C2=0,999,A2:C2)),2)))
E15E15=LET(arry,HSTACK(B3,B5,A5),IF(SUM(arry)=0,"Nil",TEXTJOIN(" : ",,ROUND(arry/MIN(IF(arry=0,999,arry)),2))))
formula below in E15 for an idea on that scenario.
Maybe Nesting another If error type statement with the haystack formula to define how to handle certain zero cases. I did this before using just MIN, but it became a puzzle trying to nest multiple Ifs with iferrrors to try and account for every possibility, so not real easy to read if you have to come back to it in the future and understand what is it doing.
 
Upvote 0

Forum statistics

Threads
1,216,193
Messages
6,129,447
Members
449,509
Latest member
ajbooisen

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