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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
mariner84
Advocate I
Advocate I

Query Editor help

Hello,

I'm having trouble figuring out how to create a custom column to categorize Age.

In the picture below I have employees and their age, I would like the custom column to categorize into:

<25

25 - 30

31 - 35

36 - 40

41 - 45

46 - 50

51 - 55

55 - 60

61 - 65

66+

 

Age.JPG

 

Is this possible in Query Editor? I tried a conditional column but couldnt get it to work out so my next try would be Custom Column, but I'm not even sure if that would work. Hoping for someone to help here 😃

 

Thank you

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi,

You can do it in query editor using conditinal columns.

Here's the M-code that got generated for a sample dataset.

You can change it to suit your age group requirements.

= Table.AddColumn(#"Changed Type", "Age Group", each 
if [Age] <= 10 then "1 - 10" 
else if [Age] <= 20 then "11 - 20" 
else if [Age] <= 30 then "21 - 30" 
else "Other"
)

result.PNG

Please accept this as a solution if it satisfies the requirement. Appreciate your Kudos. 🙂

 

Thanks.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi,

You can do it in query editor using conditinal columns.

Here's the M-code that got generated for a sample dataset.

You can change it to suit your age group requirements.

= Table.AddColumn(#"Changed Type", "Age Group", each 
if [Age] <= 10 then "1 - 10" 
else if [Age] <= 20 then "11 - 20" 
else if [Age] <= 30 then "21 - 30" 
else "Other"
)

result.PNG

Please accept this as a solution if it satisfies the requirement. Appreciate your Kudos. 🙂

 

Thanks.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.