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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
JohnCarl45
Helper I
Helper I

How to convert 0.1, 0.2, 0.3, 0.4, 0.5 months into 0-1 Years Using Dax

Hi folks, good day. I have a problem with my data set: how to convert 0.1 to 0.9 months into 0–1 years and 1.1  to 5 years into 1–5 years.
6.1 to 10 into 5–10 years, 11.1 to 15 into 10-15 years, and 15.1  to 20 into 15 years and above. Btw, here's the sample data. As you see, the column Years of Tenured is the one that I want to convert into text, like 0–1 years, etc., and the Years of Service column is the finished product when I convert those Years of Tenured values using Dax. The question is, what formula of dax will I use to convert those values in the Years of Tenured column to get the value in the Years of Service column? It's a big help if you answer this question. Thank you Very much

Years of Tenured           Years of service
0.1                                 0-1 Years
0.2                                 0-1 Years
0.3                                 0-1 Years

1.0                                 0-1 Years
1.1.                                0-1 Years
1.2                                 0-1 Years                            
1.3                                 0-1 Years
1.4                                 0-1 Years
2.0                                 1-5 Years
2.1                                  1-5 Years
2.2                                  1-5 Years
2.3                                  1-5 Years
3.0                                  1-5 Years
3.1                                  1-5 Years
3.2                                  1-5 Years
3.3                                  1-5 Years
4.0                                  1-5 Years
4.1                                  1-5 Years
4.2                                  1-5 Years
4.3                                  1-5 Years
5.0                                  1-5 Years
5.1                                  1-5 Years
5.2                                  1-5 Years
5.3                                  1-5 Years                     
6.0                                  5-10 Years
6.1                                  5-10 Years
6.2                                  5-10 Years
6.3                                  5-10 Years
7.0                                  5-10 Years
7.1                                  5-10 Years
7.2                                  5-10 Years
7.3                                  5-10 Years
8.0                                  5-10 Years                                
8.1                                  5-10 Years
8.2                                  5-10 Years
8.3                                  5-10 Years
9.0                                  5-10 Years
9.1                                  5-10 Years
9.2                                  5-10 Years
9.3                                  5-10 Years
10                                   5-10 Years
10.1                                5-10 Years
10.2                                5-10 Years
10.3                                5-10 Years
11                                  10-15 Years
11.1                                10-15 Years
11.2                                10-15 Years
11.3                                10-15 Years
12                                   10-15 Years
12.1                                10-15 Years
12.2                                10-15 Years
12.3                                10-15 Years
13                                  10-15 Years
13.1                               10-15 Years
13.2                               10-15 Years
13.3                               10-15 Years
14                                  10-15 Years
14.1                               10-15 Years
14.2                               10-15 Years
14.3                               10-15 Years
15                                  10-15 Years
15.1                               10-15 Years
15.2                                10-15 Years
15.3                                10-15 Years
16                                   15 Years Above
16.1                                 15 Years Above
16.2                                 15 Years Above
16.3                                 15 Years Above
17                                    15 Years Above
17.1                                 15 Years Above
17.2                                 15 Years Above
17.3                                 15 Years Above
18                                    15 Years Above
18.1                                  15 Years Above
18.2                                  15 Years Above
18.3                                   15 Years Above
19                                      15 Years Above
19.1                                   15 Years Above
19.2                                    15 Years Above
19.3                                     15 Years Above
20                                        15 Years Above

3 ACCEPTED SOLUTIONS
freginier
Super User
Super User

Hello @JohnCarl45  

Do you try to do this using a new table in power bi linked to your data ? I think it easier than a DAX formula

 

Richard

Data SL Consulting

 

View solution in original post

Jihwan_Kim
Super User
Super User

Hi, 

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below.

It is for creating a new column.

And I suggest having a category table (disconnected table) like below.

 

Jihwan_Kim_2-1719411220453.png

 

 

 

Jihwan_Kim_1-1719411188925.png

 

 

Jihwan_Kim_0-1719411156596.png

 

 

Years of service CC =
MAXX (
    FILTER (
        Category,
        Data[Years of Tenured] >= Category[Min]
            && Data[Years of Tenured] <= Category[Max]
    ),
    Category[Category]
) & " Years"

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

Elcin_7
Helper I
Helper I

You can create a conditional column in power Query. 

or

 

you can adjust  formula below depending your needs. Also formula might need some adjustment depending your years of Tenured colum is number or text. In this formula column data type is decimal number.

 

Tenure Category =
IF(
    SELECTEDVALUE('table name'[Years of Tenured]) < 2,
    "0-1 Years",
    IF(
        SELECTEDVALUE('table name'[Years of Tenured]) >= 2 && SELECTEDVALUE('table name'[Years of Tenured]) < 5,
        "1-5 Years",
        IF(
            SELECTEDVALUE('table name'[Years of Tenured]) >= 6 && SELECTEDVALUE('table name'[Years of Tenured]) < 10,
            "5-10 Years",
            IF(
                SELECTEDVALUE('table name'[Years of Tenured]) >= 10,
                "10+ Years",
                "Unknown"
            )
        )
    )
)

View solution in original post

4 REPLIES 4
Elcin_7
Helper I
Helper I

You can create a conditional column in power Query. 

or

 

you can adjust  formula below depending your needs. Also formula might need some adjustment depending your years of Tenured colum is number or text. In this formula column data type is decimal number.

 

Tenure Category =
IF(
    SELECTEDVALUE('table name'[Years of Tenured]) < 2,
    "0-1 Years",
    IF(
        SELECTEDVALUE('table name'[Years of Tenured]) >= 2 && SELECTEDVALUE('table name'[Years of Tenured]) < 5,
        "1-5 Years",
        IF(
            SELECTEDVALUE('table name'[Years of Tenured]) >= 6 && SELECTEDVALUE('table name'[Years of Tenured]) < 10,
            "5-10 Years",
            IF(
                SELECTEDVALUE('table name'[Years of Tenured]) >= 10,
                "10+ Years",
                "Unknown"
            )
        )
    )
)
Jihwan_Kim
Super User
Super User

Hi, 

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

I tried to create a sample pbix file like below.

It is for creating a new column.

And I suggest having a category table (disconnected table) like below.

 

Jihwan_Kim_2-1719411220453.png

 

 

 

Jihwan_Kim_1-1719411188925.png

 

 

Jihwan_Kim_0-1719411156596.png

 

 

Years of service CC =
MAXX (
    FILTER (
        Category,
        Data[Years of Tenured] >= Category[Min]
            && Data[Years of Tenured] <= Category[Max]
    ),
    Category[Category]
) & " Years"

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thank you so much sir it works!

freginier
Super User
Super User

Hello @JohnCarl45  

Do you try to do this using a new table in power bi linked to your data ? I think it easier than a DAX formula

 

Richard

Data SL Consulting

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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