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
tellech
New Member

New column IF function literal token error

Hello everyone,

 

I'm new to Power BI and its Data editor.

I'm trying to create a new column of Age Range using the IF function.

Here's my code line:

if #[AGE_MOYEN] >= 65, "65ans et plus", 
if #[AGE_MOYEN] >= 60 and #[AGE_MOYEN] = 64, "60/64 ans", 
if #[AGE_MOYEN] >= 55 and #[AGE_MOYEN] = 59, "55/59 ans",
if #[AGE_MOYEN] >= 50 and #[AGE_MOYEN] = 54, "50/54 ans",
if #[AGE_MOYEN] >= 45 and #[AGE_MOYEN] = 49, "45/49 ans",
if #[AGE_MOYEN] >= 40 and #[AGE_MOYEN] = 44, "40/44 ans", 
if #[AGE_MOYEN] >= 35 and #[AGE_MOYEN] = 39, "35/39 ans",
if #[AGE_MOYEN] >= 30 and #[AGE_MOYEN] = 34, "30/34 ans",
if #[AGE_MOYEN] >= 25 and #[AGE_MOYEN] = 29, "25/29 ans",
if #[AGE_MOYEN] >= 20 and #[AGE_MOYEN] = 24, "20/24 ans",
if #[AGE_MOYEN] < 20 , "-20 ans"

But i have this message error "Literal Token expected", showing me i need a literal token in [AGE_MOYEN]. I cant find a way to solve this.

 

Can someone give some tips?

 

Regards,

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@tellech , if this is dax column, it need to like

 

Switch(True() ,
[AGE_MOYEN] >= 65, "65ans et plus",
[AGE_MOYEN] >= 60 && [AGE_MOYEN] = 64, "60/64 ans",
[AGE_MOYEN] >= 55 && [AGE_MOYEN] = 59, "55/59 ans",
[AGE_MOYEN] >= 50 && [AGE_MOYEN] = 54, "50/54 ans",
[AGE_MOYEN] >= 45 && [AGE_MOYEN] = 49, "45/49 ans",
[AGE_MOYEN] >= 40 && [AGE_MOYEN] = 44, "40/44 ans",
[AGE_MOYEN] >= 35 && [AGE_MOYEN] = 39, "35/39 ans",
[AGE_MOYEN] >= 30 && [AGE_MOYEN] = 34, "30/34 ans",
[AGE_MOYEN] >= 25 && [AGE_MOYEN] = 29, "25/29 ans",
[AGE_MOYEN] >= 20 && [AGE_MOYEN] = 24, "20/24 ans",
[AGE_MOYEN] < 20 , "-20 ans")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@tellech , if this is dax column, it need to like

 

Switch(True() ,
[AGE_MOYEN] >= 65, "65ans et plus",
[AGE_MOYEN] >= 60 && [AGE_MOYEN] = 64, "60/64 ans",
[AGE_MOYEN] >= 55 && [AGE_MOYEN] = 59, "55/59 ans",
[AGE_MOYEN] >= 50 && [AGE_MOYEN] = 54, "50/54 ans",
[AGE_MOYEN] >= 45 && [AGE_MOYEN] = 49, "45/49 ans",
[AGE_MOYEN] >= 40 && [AGE_MOYEN] = 44, "40/44 ans",
[AGE_MOYEN] >= 35 && [AGE_MOYEN] = 39, "35/39 ans",
[AGE_MOYEN] >= 30 && [AGE_MOYEN] = 34, "30/34 ans",
[AGE_MOYEN] >= 25 && [AGE_MOYEN] = 29, "25/29 ans",
[AGE_MOYEN] >= 20 && [AGE_MOYEN] = 24, "20/24 ans",
[AGE_MOYEN] < 20 , "-20 ans")

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 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.