cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
asood23
New Member

Error for if statement

Hi Guys,
So I'm fairly new to this and would like some help over here.
For my dataset I created a column Age with randbetween function and values from 10 to 28. So this column is formed correctly. Now I wanted to create another column and divide these ages into groups like 10-12 should be kids, 13-19 should be teens, and rest should be adults.
Normally I would create a conditional column but the section doesnt show the column Age and I'm guessing thats because I used the randbetween function which is ok so I tried to do it by creating a new column by 

Age group = IF('Sheet1 (2)'[Age]>=10,'Sheet1 (2)'[Age]<=12,"Kids") & IF('Sheet1 (2)'[Age]>12,'Sheet1 (2)'[Age]<=19,"Teens")& IF('Sheet1 (2)'[Age]>=20,"Adults")
Still getting some errors.

Any help will be appreciated!
TIA.
1 ACCEPTED SOLUTION
asood23
New Member

Turns out if and, if and and if works perfectly

 

Age group = IF(AND('Sheet1 (2)'[Age]>=10,'Sheet1 (2)'[Age]<=12),"Kids") & IF(AND('Sheet1 (2)'[Age]>12,'Sheet1 (2)'[Age]<=19),"Teens")& IF('Sheet1 (2)'[Age]>=20,"Adults")

View solution in original post

1 REPLY 1
asood23
New Member

Turns out if and, if and and if works perfectly

 

Age group = IF(AND('Sheet1 (2)'[Age]>=10,'Sheet1 (2)'[Age]<=12),"Kids") & IF(AND('Sheet1 (2)'[Age]>12,'Sheet1 (2)'[Age]<=19),"Teens")& IF('Sheet1 (2)'[Age]>=20,"Adults")

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Show episode 9

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 25

Ted's Dev Camp - August 25, 2022

Watch Session 25 of Ted's Dev Camp.

Top Solution Authors