Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Improve Existing Dax via Calculated Column

Hi All,

 

I have a dataset similar to the below.

 

UP Activity/Skill TypeCalculated Column
_Day Work
_Day Work
Unit RateUnit Rate
Non BillableUnit Rate
Non-Billable ZeroUnit Rate
OverheadUnit Rate

I have a existing calculated column that searchs a column and if a "_" is found creates a row as "Day Work" and if not true "Unit Rate".

 

Calculated Column = IF(
    ISERROR(
        SEARCH("_", Employees[UP Activity/Skill Type])
    ),
    "Unit Rate",
    "Day Work")

 

I want to extend the DAX to say the following

 

If "_" is found = "Day Work"

If "Unit Rate" is found = "Unit Rate"

If anything else is found = "Non Billable"

 

Any ideas on how I can achieve this?

 

Many thanks 

  • Hi Anonymous ,

     

    Try this:-

    Column = SWITCH(TRUE(),
    CONTAINSSTRING('Table (2)'[UP Activity/Skill Type],"_"),"Day Work",
    CONTAINSSTRING('Table (2)'[UP Activity/Skill Type],"Unit Rate"),"Unit Rate",
    "Non Billable")

     

    Output:-

     

    Thanks,

    Samarth

     

     

1 Reply

  • Samarth_18's avatar
    Samarth_18
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous ,

     

    Try this:-

    Column = SWITCH(TRUE(),
    CONTAINSSTRING('Table (2)'[UP Activity/Skill Type],"_"),"Day Work",
    CONTAINSSTRING('Table (2)'[UP Activity/Skill Type],"Unit Rate"),"Unit Rate",
    "Non Billable")

     

    Output:-

     

    Thanks,

    Samarth