Forum Discussion

holywasabi's avatar
holywasabi
Frequent Visitor
1 year ago
Solved

Return value from another column based on conditions

Hi folks

 

I have a table called "Employee History", it has a column named "Salary".

 

Appreciate any help offered, much thanks!

 

I want to create a calculated column called "Salary Sort col" : 

  • Conditions will be based on a supporting table named "Salary sort"
  • Supporting table --> "Salary sort" has 3 columns : Salary Range, Min, Max
  • IF(
        'Employee History'[salary] >= SELECTEDVALUE( 'Salary sort'[Min] )
        &&
        'Employee History'[salary] <=  SELECTEDVALUE( 'Salary sort'[Max] ),
        SELECTEDVALUE( 'Salary sort'[Salary Range] )
    )
     

 

 

Idk what I'm doing wrong but my calculated column shows nothing ğŸ˜…

 

File link : https://drive.google.com/file/d/1fX_QSxj3OVJhG3jGk9hLuZXz5sUFESPF/view?usp=sharing

  • Hi holywasabi ,

     

    I would suggest you to create a calculated column as below to achieve the requirement.

     

    Salary Range  = If(Salary >0 && Salary < 39999,"Below $40k",if(Salary >39999 && Salary < 59999,"$40 - $59k", and so on)

     

    let me know if this helps.

     

    Thanks,

     

    Ankur

  • Salary Range col =
    CALCULATE (
        VALUES ( 'Salary sort'[Salary Range] ),
        FILTER (
            'Salary sort',
            'Employee History'[salary] >= 'Salary sort'[Min]
                && 'Employee History'[salary] <= 'Salary sort'[Max]
        )
    )

     

3 Replies

  • Hi holywasabi ,

     

    I would suggest you to create a calculated column as below to achieve the requirement.

     

    Salary Range  = If(Salary >0 && Salary < 39999,"Below $40k",if(Salary >39999 && Salary < 59999,"$40 - $59k", and so on)

     

    let me know if this helps.

     

    Thanks,

     

    Ankur

  • SachinNandanwar's avatar
    SachinNandanwar
    Impactful Individual
    Salary Range col =
    CALCULATE (
        VALUES ( 'Salary sort'[Salary Range] ),
        FILTER (
            'Salary sort',
            'Employee History'[salary] >= 'Salary sort'[Min]
                && 'Employee History'[salary] <= 'Salary sort'[Max]
        )
    )