Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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,
Solved! Go to Solution.
@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")
@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")
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 5 | |
| 5 |
| User | Count |
|---|---|
| 24 | |
| 11 | |
| 9 | |
| 9 | |
| 8 |