Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
How can I create and add a new column in Power BI to mimick the excel formulas below?
=IF(NUMBERVALUE(C2)<=250,"0-250",IF(NUMBERVALUE(C2)<=500,"251-500",IF(NUMBERVALUE(C2)<=750,"501-750",IF(NUMBERVALUE(C2)<=1000,"751-1000",IF(NUMBERVALUE(C2)<=1250,"1001-1250",IF(C2="2000","2000",IF(C2="9000","9000",LEFT(C2,4))))))))
Index | Phase | first four | Section |
1 | 0001-0000 | 0001 | 0-250 |
2 | 0002-0000 | 0002 | 0-250 |
3 | 0003-0000 | 0003 | 0-250 |
4 | 0004-0000 | 0004 | 0-250 |
5 | 0004-1000 | 0004 | 0-250 |
6 | 0005-0000 | 0005 | 0-250 |
7 | 0005-1000 | 0005 | 0-250 |
2246 | 9000-1520 | 9000 | 9000 |
2247 | 9000-1530 | 9000 | 9000 |
2248 | 9000-1540 | 9000 | 9000 |
2251 | 9999-9000 | 9999 | 9999 |
2252 | 9999-9960 | 9999 | 9999 |
2253 | 9999-9970 | 9999 | 9999 |
2254 | 9999-9999 | 9999 | 9999 |
Solved! Go to Solution.
For First Four, use following DAX formula and change the column to Whole Number
First Four = LEFT('Table'[Phase],4)
For Section, use following DAX formula
SWITCH(
TRUE(),
'Table'[First Four]<=250,"0-250",
'Table'[First Four]<=500,"251-500",
'Table'[First Four]<=750,"501-750",
'Table'[First Four]<=1000,"751-1000",
'Table'[First Four]<=1250,"1001-1250",
'Table'[First Four]=2000,"2000",
'Table'[First Four]=9000,"9000",
LEFT('Table'[First Four],4)
)
For First Four, use following DAX formula and change the column to Whole Number
First Four = LEFT('Table'[Phase],4)
For Section, use following DAX formula
SWITCH(
TRUE(),
'Table'[First Four]<=250,"0-250",
'Table'[First Four]<=500,"251-500",
'Table'[First Four]<=750,"501-750",
'Table'[First Four]<=1000,"751-1000",
'Table'[First Four]<=1250,"1001-1250",
'Table'[First Four]=2000,"2000",
'Table'[First Four]=9000,"9000",
LEFT('Table'[First Four],4)
)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.