Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AlexMunday
Frequent Visitor

How to find mins in a column related to another column (excel MINIFS)

The idea is to find the min of the value column related to the department column, but the min has to be different from 0.

then we want the second and third min

 

Here are the excel function used:

Small 1 = MINIFS($C:$C;$B:$B;$B2;$C:$C;"<>0")

Small 2 =MINIFS($C:$C;$B:$B;$B2;$C:$C;"<>0";$C:$C;CONCAT("<>";$D2))

Small 3 = =MINIFS($C:$C;$B:$B;$B2;$C:$C;"<>0";$C:$C;CONCAT("<>";$D2);$C:$C;CONCAT("<>";$E2))

 

I have put some data to illustrate:

 

CountryDepartement value Min 1Min 2 Min 3
CHa0,8248310,4912410,7590350,824831
CHb00,5622870,8126210,866854
CHc0,022410,022410,095080,195738
CHd0,0323020,0323020,576650,748025
CHe0,4116740,4116740,7102190,729571
CHf0,3114020,1315880,2330240,311402
ESa0,7590350,4912410,7590350,824831
ESb0,8668540,5622870,8126210,866854
ESc00,022410,095080,195738
ESd0,7607270,0323020,576650,748025
ESe0,7295710,4116740,7102190,729571
ESf0,2330240,1315880,2330240,311402
BRa00,4912410,7590350,824831
BRb0,8126210,5622870,8126210,866854
BRc0,095080,022410,095080,195738
BRd0,576650,0323020,576650,748025
BRe0,7961080,4116740,7102190,729571
BRf0,5207320,1315880,2330240,311402
PRa0,4912410,4912410,7590350,824831
PRb0,5622870,5622870,8126210,866854
PRc0,1957380,022410,095080,195738
PRd0,7480250,0323020,576650,748025
PRe0,7102190,4116740,7102190,729571
PRf0,1315880,1315880,2330240,311402
1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @AlexMunday 

Create a calculated column for the first min:

Min1 =
CALCULATE (
    MIN ( Table1[value ] );
    ALLEXCEPT ( Table1; Table1[Departement ] );
    Table1[value] <> 0
)

Then for min2 using the newly created column:

Min2 =
CALCULATE (
    MIN ( Table1[value ] );
    ALLEXCEPT ( Table1; Table1[Departement ] );
    Table1[value] <> 0;
     Table1[value] <> EARLIER( Table1[Min1])
)

and then for min3

Min3 =
CALCULATE (
    MIN ( Table1[value ] );
    ALLEXCEPT ( Table1; Table1[Departement ] );
    Table1[value] <> 0;
    Table1[value] <> EARLIER( Table1[Min1]);
Table1[value] <> EARLIER( Table1[Min2]) )

 

View solution in original post

2 REPLIES 2
AlB
Super User
Super User

Hi @AlexMunday 

Create a calculated column for the first min:

Min1 =
CALCULATE (
    MIN ( Table1[value ] );
    ALLEXCEPT ( Table1; Table1[Departement ] );
    Table1[value] <> 0
)

Then for min2 using the newly created column:

Min2 =
CALCULATE (
    MIN ( Table1[value ] );
    ALLEXCEPT ( Table1; Table1[Departement ] );
    Table1[value] <> 0;
     Table1[value] <> EARLIER( Table1[Min1])
)

and then for min3

Min3 =
CALCULATE (
    MIN ( Table1[value ] );
    ALLEXCEPT ( Table1; Table1[Departement ] );
    Table1[value] <> 0;
    Table1[value] <> EARLIER( Table1[Min1]);
Table1[value] <> EARLIER( Table1[Min2]) )

 

Thank you it's working perfectly

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors