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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.