V
V
vasilgut2022-02-03 19:08:07
excel
vasilgut, 2022-02-03 19:08:07

How to make a correct IFS sample?

It is necessary to use three variables to calculate the grading system for employees.
Here is what is currently available:

=IFS(R3<3;"Стажёр";И(Q3>1;6>R3>=3;S3>15);"Младший";И(Q3=3;12>R3>=6;S3>30);"Средний";И(Q3=3;12<R3<18;50<=S3);"Старший";И(Q3=3;R3>18;S3=60);"РП")

61fbfca53e721145802055.png
Here are the prerequisites:
61fbfd7269860420559913.png

For some reason it does not work as it should, help me understand what's wrong.
Also link to spreadsheet in Google Sheets: https://docs.google.com/spreadsheets/d/1i97T3OooMG...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2022-02-03
@vasilgut

EYANO, three arrays of conditions.
I dashed off the formula for V3 :

=LOOKUP(
  MATCH(
    1
    ;ArrayFormula(
      {Q3=1;Q3=1;Q3=2;Q3=3;Q3=3;Q3=3}
      *{R3<3;R3<3;AND(R3>=3;R3<6);AND(R3>=6;R3<12);AND(R3>=12;R3<18);R3>18}
      *{S3<=13;S3>13;S3>=20;S3>=25;S3>=30;S3>=35}
    )
    ;0
  )
  ;{1;2;3;4;5;6}
  ;{"К увольнению";"Стажёр";"Младший";"Средний";"Старший";"РП"}
)

  1. {Q3=1;Q3=1;Q3=2;Q3=3;Q3=3;Q3=3}  — array of conditions for knowledge of the language;
  2. {R3<3;R3<3;AND(R3>=3;R3<6);AND(R3>=6;R3<12);AND(R3>=12;R3<18);R3>18}  — an array of conditions for experience;
  3. {S3<=13;S3>13;S3>=20;S3>=25;S3>=30;S3>=35}  — array of conditions for the total number of points.

*******
Via IFS():
=IFS(
     AND(Q3=1;R3<3;S3<=13);"К увольнению"
    ;AND(Q3=1;R3<3;S3>13);"Стажёр"
    ;AND(Q3=2;AND(R3>=3;R3<6);S3>=20);"Младший"
    ;AND(Q3=3;AND(R3>=6;R3<12);S3>=25);"Средний"
    ;AND(Q3=3;AND(R3>=12;R3<18);S3>=30);"Старший"
    ;AND(Q3=3;R3>18;S3>=35);"РП"
)

G
Grigory Boev, 2022-02-03
@ProgrammerForever

This may help - the implementation of a piecewise constant function

/**
 * Рассчитывает кусочно-константную функцию
 *
 * @author Boew Grigory ([email protected])
 * @param {Array} data Входные данные (аргумент)
 * @param {Array} criteria Массив критериев [от, до, значение]
 * @param {any} [defaultValue=""] Значение по умолчанию - то что подставляется, если аргумент не подходит ни под один из критериев
*/
function piecewiseConstant(data, criteria, defaultValue="-"){
  criteria = criteria
              .map(cr=>({ // convert to objects
                fromValue: cr[0],
                toValue: cr[1],
                value: cr[2],
              }))
              .filter(cr=>cr.fromValue!=="" && cr.toValue!==""); // filter empty criteria
  return data.map(row=>row.map(el=>{
    let foundCriteria = criteria.find(cr=>(el>=cr.fromValue)&&(el<cr.toValue));
    if (foundCriteria!==undefined){
      return foundCriteria.value;
    }else{
      return defaultValue;
    };
  }));
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question