Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
Please I need help with changing age range in text to numbers on Power BI desktop.
The aage column has the following sample ranges:
Total - Age
15 to 24 years
25 to 29 years
I replacec the first "Total - Age" to "0-100" so I can convert the others to numbers. It gave errors. I replaced the "to" into "-".
I replaced "years" with " ". I then tried changing the data type to whole number. It still gave errors. How do I then chenge the column from text type to whole numbers?
Thank you.
@Mariaoye , what is the expected output.
You can have a column like
Switch( True(),
[Total - Age] = "Total - Age" , 0,
left([Age],2)
)
or
left([Age], search(" ",[Age],1,0) -1)
What number do you want exactly? If it's just some number in the range, can you not just extract the first two characters of the field?
Thanks for your response. I want to have a range in numbers that I can use to plot graphs. This is a dataset I got about income and I just want to plot the incomes based on the age ranges.
15-24
25-34.....
Hi @Mariaoye ,
If your expected output is 15-24, 25-34, etc., then how is it going to be whole number? This will always be text datatype.
Also, you can also create groups based on the Age. Right click on age field and create new group.
Give a thumbs up if this post helped you in any way and mark this post as solution if it solved your query !!!
@Anand24 Thanks. I guess I was looking at it all wrong.
I can only create categorical fields with range and not numeric. I want to believe that is what you meant.
Cheers.
@Mariaoye,
Yes, that's exactly what i meant. Your range can never be in whole number format.
Thanks for your response. I want to have a range in numbers that I can use to plot graphs. This is a dataset I got about income and I just want to plot the incomes based on the age ranges.
15-24
25-34....
User | Count |
---|---|
98 | |
90 | |
77 | |
71 | |
64 |
User | Count |
---|---|
114 | |
97 | |
95 | |
68 | |
65 |